I want to save the data instead of restore it when I select another row. How I can accomplish that?
I’ve been testing with this code without any results:
onSelectRow: function(row_id) {
if(row_id && row_id !== last_selected) {
/*
* Save row.
*/
$('#grid').jqGrid('saveRow', ((last_selected !== undefined)?last_selected:row_id) , true, function() {/* OnEditFunction */}, function(response) {
/* SuccessFunction */
var row_to_save = ((last_selected !== undefined)?last_selected:row_id);
success_function(row_to_save, response);
}, 'http://some_url.com');
last_selected = row_id;
}
/*
* Edit row.
*/
$('grid').jqGrid('editRow', row_id, true, function() {/* OnEditFunction */}, function(response) {
/* SuccessFunction */
success_function(row_id, response);
}, 'http://some_url.com');
},
It could be great if I could be able to fire a success function before the row is saved successfully, so I can show a notification message.
Thanks in advance.
I suppose that you have the problem because one small error in your current implementation of the
succesfuncwhich you use in saveRow or editRow. The method editRow just forward thesuccesfuncparameter to saveRow, so you will find the detailed description of thesuccesfuncparameter in the documentation of the saveRow. You can read the following:So you should at least include
return true;as the last statement of your implementation of thesuccesfunc.