Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make only selected Columns editable in ShieldUI Grid?

I am using ShieldUI for making an editable Grid on a webpage. A very similar grid can be found at this URL.

My requirement is to make only 1 column editable while keeping the remaining columns as non-editable in the above Grid.

The Documentation of the ShieldUI provides option to enable or disable editing of the whole Grid at a time. However, it provides no option to enable or disable editing at column level.

I could not find any good resource on the web on this topic.

As a possible solution, we can enforce the edit disable using Javascript, but I think that would destroy its simplicity.

How can we achieve this? Any help would be highly appreciated.

Thanks

like image 706
Abhishek Bharadwaj Avatar asked Oct 20 '22 02:10

Abhishek Bharadwaj


2 Answers

I was having a similar problem, I used the editorCreating event to enable/disable the default control behavior. I am using row editing in this example.

https://www.shieldui.com/documentation/grid/javascript/api/events/editor-creating

Ex.

events: {
     editorCreating: function(e) {
        if (e.field == "column_i_want_to_disable") {
            e.options = { enabled: false };
         }
    },
like image 56
Andrew Fessenden Avatar answered Nov 01 '22 13:11

Andrew Fessenden


You should be able to cancel the editing on a row by overriding the command event, described here: https://www.shieldui.com/documentation/grid/javascript/api/events/command

Before a row goes in editing mode, an "edit" command is sent, which can be caught by the command event described above.

Inside the event handler you can inspect the row being edited and cancel the editing it if needed.

like image 25
Vladimir Georgiev Avatar answered Nov 01 '22 12:11

Vladimir Georgiev