tonytomov / jqGrid

jQuery grid plugin

Home Page:www.trirand.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setCell not applying formatter

unle70 opened this issue · comments

Looks to me that when using the "setCell" method, the value is going into the grid without applying the set formatter. My questions:

  1. Am I correct in my observation or is it just something in my environment?
  2. Is this a bug or a feature? :)
  3. If this is done on purpose, is there a function call I can make by myself to apply the set formatter before calling setCell?

Thanks,
Udi

Hello,

Sorry for delay.
SetCell method uses a formatting, but there are conditions when this not apply.

See here:
https://github.com/tonytomov/jqGrid/blob/master/js/grid.base.js#L6752

The conditions where the setCell fail are

  • rowId and colname does not exists
  • the indexRow can not be get with getGridRowById
  • the cell can not be get with indexRow.cells[pos]
  • if the new cell content is empty string (this can be omited with the 6-th parameter forceupdate) - see docs

Check if these conditions are correct.

Hi Tony,

Well, you pointed me to the interesting area in the code and then I did some debugging from there.
Eventually I could see that the formatter IS being called, but the problem was elsewhere.
My field is "datetime" type. When the setCell is called manually (like I use it), the formatter is invoked with the "edit" parameter. In that case there's a condition in the below line which needs "reformatAfterEdit" in order to use the formatter. Otherwise it uses the default formatter. Once I added "reformatAfterEdit : true" to my formatoptions, everything started working well. Not sure if this is a bug or just something to live with.

if(!op.reformatAfterEdit && act === 'edit'){

Anyway, thank you for the tip.