I\'m wondering how I can trigger reloadGrid after an inline edit of a row.
From the docs, I think afterSaveCell
will work best for you (afterSubmitCell
could work as well but it seems to require a specific return value. afterEditCell
happens before the server hit occurs so that will be too soon).
jQuery('#grid').jqGrid('editRow', id, true, reload);
jQuery(document).ready(function(){
var lastcell;
jQuery("#grid").jqGrid({
// [snip earlier config]
onSelectRow: function(id){
if(id && id!==lastcell){
jQuery('#grid').jqGrid('restoreRow',lastcell);
jQuery('#grid').jqGrid('editRow',id,true);
lastcell=id;
}
},
editurl:"{% url set_hour_record_json_set %}",
onAfterSaveCell: reload
}).navGrid('#gridpager');
});
function reload(result) {
$("#grid").trigger("reloadGrid");
}
However, reloading the entire grid is probably overkill given the information you've described so far. Unless there is server side processing of submitted information (meaning the data in the db might different after a save), reloading after a simple edit seems to me like a waste of time.
As for when you are creating a new row, again, unless there is server-side only data munging it seems like it would be easier to just get the new id from the submit and then make that individual change in jqGrid. However, in the end it depends a lot on how long it takes reload your whole table.