How to setup jqGrid Cell Editing Events?
I have an input box in a jqGrid grid that displays utilizeds the JQuery Hint plugin to add some text to blank input boxes when a user edits a row of my grid. In the event that the user doesn't modify a text box that contains the hint text, I need to remove the hint (reverting the textbox to its empty state) before saving.
I assume the beforeSaveCell event is the way to go on this, as described in the documentation. However, I can't for the life of me figure out how to get Cell Editing events to fire. The docs state:
These events are related to cell editing and should be used in grid options.
I assume that means I should put this in the config like so:
$("#myGrid").jqGrid({
url:'url.php',
datatype: 'json',
pager: '#pager',
hidegrid: false,
cellEdit: true,
befor开发者_如何学JAVAeSaveCell: beforeSaveFunction,
...
However, my function doesn't seem to fire when setup like above. Putting the function in the colModel didn't work either. For some reason, I couldn't find any examples... what am I doing wrong?
Thanks!
Probably you have some problems in the implementation of beforeSaveFunction
. First of all try with
beforeSaveCell: function(rowid,celname,value,iRow,iCol) {
alert('New cell value: "'+value+'"');
}
The function will be called of cause only if the cell value will be modified. By the way, if the function returns a string value which is not equal to empty string "", the returned valued will be used as the new modified cell value.
精彩评论