tonytomov / jqGrid

jQuery grid plugin
www.trirand.com
2.84k stars 1.2k forks source link

setCell not applying formatter #1017

Open unle70 opened 1 year ago

unle70 commented 1 year ago

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

tonytomov commented 1 year ago

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

Check if these conditions are correct.

unle70 commented 1 year ago

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.

https://github.com/tonytomov/jqGrid/blob/f104df4bbbe6abeafd22d7a5c8784c5da732079f/js/jquery.fmatter.js#L214

Anyway, thank you for the tip.