开发者

jqGrid - Trigger reloadGrid inside afterSaveCell method

开发者 https://www.devze.com 2023-03-18 16:22 出处:网络
I\'m trying to reload my grid after modifying a cell but I get this error message: \"Error in ajax request\".

I'm trying to reload my grid after modifying a cell but I get this error message: "Error in ajax request".

Here's my开发者_运维百科 function:

afterSaveCell: function(rowid, name, val, iRow, iCol){  
    //... do some stuff ...  
    //save cell in the database  
    //... some more stuff ...  
    $("#grid").trigger("reloadGrid")  
}

This grid is built on the server (I know my columns only at runtime), so I'm thinking that I should fire the hole $.ajax() function (in which all the grid definition is). Is this right? How can I do it?


I didn't find a way of doing this. So I did the ajax request (which saves the values in the database) inside the afterSubmitCell event and then calculate the rest of the fields inside afterSaveCell (using javascript and a lot of getCell and setCell calls).

In fact this ended up being a better way of doing this since the user doesn't have to wait more than 1 second to see the updated values. Also the documentation of the afterSaveCell event says:

Applies only to a cell that is editable; this event fires after the cell has been successfully saved. This is the ideal place to change other content.

The downside of going this way is that I have duplicated logic to calculate some columns of the grid (server-side in C# and client-side in javascript)

0

精彩评论

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

关注公众号