开发者

jqGrid set cells data while inline edit active

I think it's a stupid question but I can not find a solution. I created a table with jqGrid and I enabled inline editing On each line I added a button that enables or disables editing I wanted to add a second button active only during editing that would allow you to load the default values ​​in the various fields of active inline edit row. I do not know how to access and change data row while editing setRowData work well if row i selected but not in inline edit mode Anyone have any suggestions, thanks.

Update I have found a (bad I think) solution but explain my problem:

 if (edit_enable开发者_高级运维d) {
     // save current data
     jQuery('#SEQtbl').jqGrid('saveRow',row_edit, false, 'clientArray');

     // read back row data
     var row = jQuery("#SEQtbl").jqGrid('getRowData',row_edit);

     // change something  
     ....
     .....

     // save data
     jQuery("#SEQtbl").jqGrid('setRowData',row_edit, row);

     // reneter row edit mode
     jQuery('#SEQtbl').jqGrid('editRow', row_edit,true);
   }

`


I think you've already got your answer in the code you posted.

According to the jqGrid documentation for setRowData "Do not use this method when you editing the row or cell. This will set content and and overwrite the input elements". Basically, when you call setRowData or getRowData on a row that is in edit mode, you get/set the HTML of the row, not the data.

I'm not sure of what your requirements are, but it may be a better UI solution to have the "set default values" button active at the same time as the enable/disable edit buttons. The user can click "set defaults", and it will set the defaults, then enter edit mode.

I don't quite understand why you have this "set defaults" button to begin with. Shouldn't the defaults be loaded when the new row is added? Or is it the case that your users may want to reset a row that already has data back to the default values?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜