Forum Discussion
Column formatting not showing when view shown in a List Web Part (Modern Page and List)
Hi Hjalmar Otto Fjøsne ,
Sorry to hear that, but can you please share more details around the issue.
Do you have the JSON which was applied to the column? And what do you mean that the JSON do not show in "Format this column" option? Are you saying that you are able to see the formatted column but there isn't any JSON when you open the formatting pane?
If you are also not able to see that formatting being applied, can it be possible that some other user, who has the edit access on the list, must have removed the formatting?
It would really help in debugging if you can share the JSON you are using which isn't showing on the webpart but is working fine when you navigate to the list.
- DylanMMurphyOct 21, 2021Copper Contributor
SVaibhav LincolnDeMaris I've got some very simple JSON formatting one column to have a clickable link to a URL in another column. It works great in the list, and when you first add it to a modern page, it looks fine too, but if I go to edit and then select a specific view, and then hit publish, the formatting is gone. JSON still works if you don't edit the list before publishing. More unusual is that if you click See All on the Modern Page, when the list comes up, the formatting is also not visible there anymore, even though the JSON is still there. Any help would be wildly appreciated.
UPDATE: I just realized that the Link field must be visible in the View for the JSON to work in a Modern Page. Works just fine with the List itself, but not when added to a Modern Page. Hope this helps someone!
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "children": [ { "elmType": "span", "txtContent": "@currentField", "style": { "display": "=if([$Link] != '', 'none', 'block')" } }, { "elmType": "a", "txtContent": "@currentField", "attributes": { "target": "_blank", "href": "[$Link]" }, "style": { "display": "=if([$Link] != '', 'block', 'none')" } } ] }
when adding to modern page, if i don't change the lists settings, it does show JSON, but if I try and specify a view or anything else, it kills it:
what it's supposed to do:
what it actually does after clicking See All:
- Weblin18_1Sep 09, 2020Copper Contributor
Hello,
I have added the basic button from the Microsoft Documentation for editProps and it works fine in the library view, but when added to a modern page the button either does nothing or tries to open the document rather than the properties. Reading through this thread I cannot tell if that is still to be expected or not?
Thanks.
Code for reference:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "button", "txtContent": "Open this item", "customRowAction": { "action": "editProps" } }