Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setCell not applying formatter #1017

Open
unle70 opened this issue Sep 1, 2022 · 2 comments
Open

setCell not applying formatter #1017

unle70 opened this issue Sep 1, 2022 · 2 comments

Comments

@unle70
Copy link

unle70 commented Sep 1, 2022

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
Copy link
Owner

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.

@unle70
Copy link
Author

unle70 commented Sep 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants