jsoneditor icon indicating copy to clipboard operation
jsoneditor copied to clipboard

Urgent problem of partial modify and provide delete function

Open MichaelPanwenjie opened this issue 2 years ago • 7 comments

I am using jsonedit to add, delete, check and change mongodb data in the angular project. What I want now is :

  1. Let jsonedit only can modify value, can not modify keys,
  2. You cannot add data structures. You can delete some structures, but you cannot add additional ones
  3. Jsonedit has the function of remove
  4. Verify data validity

How do you realize this requirement?can give me a simple, thanks!

MichaelPanwenjie avatar Sep 10 '22 03:09 MichaelPanwenjie

Have you see the options onEditable, schema, and onValidate? I think these options can more or less cover your list.

See docs: https://github.com/josdejong/jsoneditor/blob/master/docs/api.md And you can search the examples for usage examples of the mentioned options: https://github.com/josdejong/jsoneditor/tree/develop/examples

josdejong avatar Sep 12 '22 07:09 josdejong

I used onEditable function, it can make keys uneditable,but when i using it the remove function has been lost.

Can you give me some short examples or related links to reference ,it is urgent. Thanks a lot!

MichaelPanwenjie avatar Sep 12 '22 08:09 MichaelPanwenjie

I used onEditable function, it can make keys uneditable,but when i using it the remove function has been lost.

I'm not sure what you mean exactly. When you make a key uneditable, you can indeed not remove this field.

josdejong avatar Sep 12 '22 13:09 josdejong

Okay, I see. - But can I control the insert function? If all the keys exist then disable insert, If any key is missed then enable insert function? Waiting for your replay,thanks!

MichaelPanwenjie avatar Sep 12 '22 13:09 MichaelPanwenjie

Yes, you can modify the buttons shown in the context menu with the option onCreateMenu if the default behavior of what onEditable disabled does not match your needs.

josdejong avatar Sep 12 '22 13:09 josdejong

but how can i get the context menus ? From any public object ?

MichaelPanwenjie avatar Sep 13 '22 03:09 MichaelPanwenjie

No, you can implement the onCreateMenu callback and in that callback you can add or remove buttons. There is an example here: https://github.com/josdejong/jsoneditor/blob/develop/examples/21_customize_context_menu.html

josdejong avatar Sep 16 '22 11:09 josdejong