JQgrid - onCellSelect does not trigger for cell editing

64 Views Asked by At

In JQgrid, if you want to do some pre-processing stuff before the cell of a table is edited ( the input is rendered on the DOM ). You can't do that, because for some reason the onCellSelect does not trigger at all. Reading the docs, it states that when doing inline cell editing, the onCellSelect event is disabled. Its kind of ambiguous, in the sense that the naming itself refers to cells being selected, so what's the reason to disable it ?

I've used the following properties to enable cell editing

   cellEdit : true,
   cellsubmit : 'clientArray',
   restoreCellonFail: true

Catching the cell selected event on

onCellSelect: (rowid, cellid, cellvalue) => {
   ....  do some stuff, like remove the formatter
}
2

There are 2 best solutions below

2
Tony Tomov On BEST ANSWER

Not sure which docs you read and which version is used, but you have two other ways to solve the problem.

  1. In case you use formatter , you can use unformat to parse the format before editing.

  2. the event beforeEditCell is more natural as name and is called just before editing

0
Pills On

Nevermind, did find the answer, if you want to modify the cell content before the input is rendered, that is, for my case, to remove the formatter before editing. Just use the event formatCell like below. Worth mentioning in the doc like in red, because its not that obvious.

   formatCell: function(rowid, cellname, value, iRow, iCol){
      let cell_value = value.replace(/(<([^>]+)>)/ig, '');
      return cell_value;
   }