Author Topic: Change value of a cell programmatically  (Read 2347 times)

NearEarthObject

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 30
    • View Profile
Change value of a cell programmatically
« on: February 23, 2020, 05:39:51 pm »
Hi
I am working on a grid, build with ajax as both regarding colModel and dataModel, through a database.

The object list has a field position. And of course, the idea is to use drag and drop to modify the position integer.
So I have a column, with position field, and i I use drag and drop.
Once move achieved, I used a function

mySelector.on("moveNode", function (event, ui) {..};

to determine new position and eventually push an ajax request to operate the change in the database.

And all is working like a charm, but at this point, I would need to change the value in each cell concerned by the position changement, to illustrate, if I move the row position 1 to row position 5, I want to change row 2 column position value to  1, row 3 column position to 2, till the moved row, who would become the number 5.
So all cell regarding position have specific identifier, I launch a simple jquery each function, who find all what I need, once i calculate the old position integer, new position integer, and simply try to push new value in the cell, nothings happen...
Push million of console.log to try to figure what's happen, no error, all looks perfect, but i can't definitively not put new value in the cell....

So i know that the alternatives would be to push new data in database, once reload data, and refresh the grid, but when the data base is rather huge, that takes a time and it's definitively not aesthetic.
I have been trying to let the column editable, or not, nothings change.
Is there some protection who prevent any incursion in cell value by jQuery ?

Any suggestions ?

Thanks in advance !

Jeff

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Change value of a cell programmatically
« Reply #1 on: February 24, 2020, 09:55:58 am »
If you are making changes directly in the grid data, then you also need to call either refresh() or refreshColumn() method, latter method if all changes are in single column.

Alternatively you can use updateRow method to make changes in cells programmatically.
« Last Edit: February 24, 2020, 10:06:40 am by paramvir »