Dadu
Dadu

Reputation: 109

Condtional editable depend on the value in colModel jqGrid

I am trying to put editable value either true or false depend on the value of the cell in colModel. Is there is any way to do that?

{name:'keywords',index:'keywords', width:150, editable:true,edittype:'select',
editrules:{required: true},
editoptions:{value:{'one':'one','two':'two','three':'three','four':'four'},size:5} },

In this I want to set editable:false if the cellvalue exist else editable:true and editoptions:{value:{'one':'one','two':'two',...} for a particular cell.

Upvotes: 1

Views: 503

Answers (1)

Oleg
Oleg

Reputation: 221997

The most easy way to implement the requirement would be to use free jqGrid. It's the fork (based on jqGrid 4.7) which I develop currently. Because of such requirements I implemented the feature described in the wiki article. It allows to define editable property as function. So you need just to define the callback from which you returns true or false base on any your custom criteria. The callback editable get many information about the context of execution as properties of the only parameter. The rowid, iRow, iCol and name properties allows you to use getLocalRow or getCell to get contain of any column of the row. So you can enable editing selectively in very simple way.

If you can't upgrade to free jqGrid then you can use old tricks which are specific for the editing mode which you use. I can forward you to the answer which can be used in case of form editing and this one which can be used in case of form editing if you call editRow directly. In case of usage inlineNav or formatter: "actions" there are alternative solutions which you can find also in my old answers.

Upvotes: 1

Related Questions