Forum Discussion
Allow users to only edit one of the fields in a list
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?
3 Replies
- SvenSieverdingBronze Contributor
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#inline-editing
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-user
Best Regards,
Sven- Samson1915Copper Contributor
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
- SvenSieverdingBronze Contributor
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