Forum Discussion
Bhavpreet Bains
Feb 21, 2018Iron Contributor
Formatting column making the column text to disappear
Hello,
I was testing Column Formatting using JSON on Name column in a document library. However, each time anything is adding, it makes the content in the column to disappear. I was trying the simplest column formatting to places the value of the field inside a <div />
element:
{ "elmType": "div", "txtContent": "@currentField" }
Not sure, if I am doing something wrong. Any help is much appreciated.
Thank you.
This should fix it
{ "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json", "elmType": "div", "txtContent": { "operator": "+", "operands": [ "[$FileName]", ".", "[$File_x0020_Type]" ] }, "style": { "color": "orange" } }
This link helped me
- Gregory MelsonCopper Contributor
This should fix it
{ "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json", "elmType": "div", "txtContent": { "operator": "+", "operands": [ "[$FileName]", ".", "[$File_x0020_Type]" ] }, "style": { "color": "orange" } }
This link helped me
- Deleted
Hello
It is nice but the folders names get "." at the end.
If there a way to distinguish Folders from Files?
Thanks
KrzysPS. there is actually one more problem. As you can see on the image below if I format the column using the following code:
{ "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json", "elmType": "div", "txtContent": { "operator": "+", "operands": [ "[$FileName]", ".", "[$File_x0020_Type]" ] }, "style": { "white-space": "normal", "color": "#000", "padding": "3px", "border-bottom-color":"grey", "border-bottom-style":"solid", "border-bottom-width":"1px" } }
Although, I am getting what I want so the full name of the files/folders wrapped within the DIV with a bottom border, Folders' names get a "." at the end and more annoyingly when you visit a folder its name and formatting disappears (see the top item in the list).
Any solutions?
- paul dallmanCopper Contributor
Deleted wrote:
Hello
It is nice but the folders names get "." at the end.
If there a way to distinguish Folders from files?
Thanks
KrzysTo remove the full stop, take
".",
out of the code.
Sorry i can't help with the Folder / File issue, as we're not using folders.
(Metadata views are the new folders!)
The problem is, that as the code is being added to the column everything within that field will adopt the same colour. So i guess you'd need to somehow differentiate between item type (Or maybe content type might )
Gregory Melson might know
- Bhavpreet BainsIron ContributorIt worked. Thank you, Gregory!
- paul dallmanCopper Contributor
Also works for list "Item" field.
- Deleted
Hi
I have exactly the same problem and it started only several days ago. Before, formatting worked fine.
Best
Krzys
- Deleted
Hello
Have anyone expierienced similar problems with column formatting in SharePoint? I would really appreciate help.
Thank you
Krzysztof