Jun 22 2023 06:16 AM
I have a list that has multiple fields. I only want users to be able to edit one of the fields and I want them to be able to do by directly clicking the items (maybe through a button?) without going to the list or using 'edit in grid'. How can I do so?
Jun 22 2023 11:34 AM
Hi @Samson1915 ,
do you mean like inline editing?
You can achieve that by applying this json formatting to all of the columns you want to make editable.
{
"elmType": "div",
"inlineEditField": "=@currentField",
"txtContent": "=@currentField"
}
See more information here https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/formatting-advanced#inlin...
Or you can do some more advanced stuff, like this sample that provides some buttons that set the approval state of an item
https://github.com/pnp/list-formatting/tree/master/column-samples/approval-buttons-setValue-status-u...
Best Regards,
Sven
Jun 22 2023 11:52 AM
Hi Sven,
Thank you for your reply. I am aware of the inlinEditField and I have tried it. I am working on the Gallery layout and when I apply the code, only the title field can be edited which is not my designated field. I wonder how I can choose which field to edit.
Best regards
Samson
Jun 22 2023 10:48 PM
Hi @Samson1915 ,
you can do the following to make a text field (like Value in my example) editable in gallery view
First copy your gallery view formatting code and put it into a text editor.
Then find the line that displays your field "Value"
"txtContent": "=if ([$Value] == '', '–', [$Value])"
and add this line above or below it.
"inlineEditField": "[$Value]",
Paste the resulting code back into the code editor on the "Format View" screen and confirm with "Save"
Now "Value" is inline editable in "Gallery View"
Best Regards,
Sven