1

I have a list of people with some data in the columns. I have managed to mark my own row, with my name in one of the columns, to have grey background. Now any one who views the list can find them self easy.

"additionalRowClass": "=if(@me == [$Person.email], 'ms-bgColor-neutralLight', '')"

But in the next step I want to hide all other rows but my own. I can not find any Class that hides the row, or any code to add custom CSS like "display: none;" to the row.

Any ideas?

0

As far as I know, there is no way to hide items with view json formatting. You could try to create a new view to filter items and show them.

0

There is no predefined class given by Microsoft to hide the complete row using additionalRowClass.

Below are couple of workarounds you can consider:

1. Create a list view with filter: Recommended

Create a new list view with [Me] filter on Person column.

Example:

enter image description here

More details at: Filter your SharePoint view to show documents requiring your action

Additionally, You can also set it as a default view if you want.

2. Use rowFormatter in JSON:

You can use rowFormatter instead of additionalRowClass which gives you more control to format list view.

Note: If you are using it you have to design your list view completely and you will loose some out of the box functionalities of SharePoint.

Similar Sample: Custom Header - In this sample, row is hiddedn based on rowIndex. Similarly you can apply your condition based on Person column to hide the row.

3. Use custom class:

If there is any class which has CSS of display: none; & it is loaded on the page where your list view is added, you can use that class in additionalRowClass like:

"additionalRowClass": "=if(@me == [$Person.email], 'ms-bgColor-neutralLight', '<class-with-custom-css>')"

You can also inject custom CSS (classes) on modern pages using SPFx extension & use those in your JSON (Injecting CSS in not recommended though).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.