简体   繁体   中英

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,
  beforeSaveCell: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM