1

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_enabled) {
     // 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);
   }

`

user954211
  • 63
  • 1
  • 2
  • 6

1 Answers1

0

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?

Walter Stabosz
  • 7,447
  • 5
  • 43
  • 75
  • thanks for the reply Walter My page displays the configuration data of a remote system. I have to fix two situations: 1 .- Bring to a default configuration, the configuration parameters are already loaded from the machine 2 .- many of the parameters are checkboxes and I needed a "short cut" to enable or disable them all together. Point 1 I can fix it as you say, set the default settings before enter edit mode. But I would like the change of data was possible only if the user enters edit mode to prevent accidental or unwanted changes. The solution I describe in my previous message works but it –  Sep 26 '11 at 13:52