dhtmlxgrid moverowsup & moverowsdown

Hi,

I would like to move the rows by using moverowsup & moverowsdown, it works fine. But in the DB also i want to move the rows up & down so that the rows will be loaded in order after I moved up or down. But when I changed the order in DB after the move the rows up, I can able to see one more row added at the end of grid. But when i reload the page I am not able to see it. How to move the rows up even in the DB without any change or refresh required in grid?

But when I changed the order in DB after the move the rows up, I can able to see one more row added
This behavior based on logic which you are using for data saving. In common case, if you are using “updateFromXML” or similar functionality to update data on client side - be sure that updated row has the same ID as original one.

>>How to move the rows up even in the DB without any change or refresh required in grid?
Grid doesn’t save row indexes through DataProcessor lib, so the only way is to send info after each operation to server side by dhtmlxAjax, or any custom sending routine.


Hi,



I am moving the rows up & down in the db when the user click move up in toolbar. But on the client side, when I try to simulate the row move up by using dhxGrid.selectRowById(prev_rowid), the grid got updated with additional unwanted rows. How to resolve it?. If I don’t use the above function, the grid updates fine.

Please provide a snippet of code which you are using to simulate row moving on client side.
By any chance are you using smart-rendering or paging mode in same time?


Please find the part of code which i am using to move down.         



          var ids=dhxGrid.getSelectedId().split(’,’);
dhxGrid.clearSelection();
                for (var i=0;i<ids.length;i++)
                {
                    next_index=dhxGrid.getRowIndex(ids[i])+1;
                    rowid=dhxGrid.getRowId(next_index);
                    dhxGrid.setUserData(ids[i],"!nativeeditor_status",“move_down”);
                    dhxGrid.setUserData(ids[i],“nx_id”,rowid);
                    dhxDataProcessor.sendData(ids[i]);
                    dhxGrid.selectRow(ids[i],false,true);
                    //dhxGrid.updateFromXML("_include/getLinkData.php");
                }
  



In the DB side I am just swaping the other values of next_index & rowid by keeping the rowid same.

The code which you are using must not cause any problem
You can try to use client side update of view, instead of reloading data from server.

next_index=dhxGrid.getRowIndex(ids[i])+1;
rowid=dhxGrid.getRowId(next_index);
dhxGrid.setUserData(ids[i],"!nativeeditor_status",“move_down”);
dhxGrid.setUserData(ids[i],“nx_id”,rowid);
dhxDataProcessor.sendData(ids[i]);
dhxGrid.selectRow(ids[i],false,true);
dhxGrid.moveRowDown(ids[i]);