Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Aug 07, 2008 08:27
open dhtmlx forum
Dataprocessor row order

Iam using grid version 1.5 and i have a strange requirement. I have a grid which allows users to update, insert,delete and move multiple rows up or down. Iam using the myDataProcessor.setTransactionMode("POST",true) to send all the data back to the server at once. I have a function which is triggered on save as follows:
function Save()
{
var status = myDataProcessor.obj.getUserData(id,"!nativeeditor_status");
mygrid.forEachRow(function(id){
if( status != 'deleted' && status != 'inserted')
{
myDataProcessor.setUpdated(id,true);
}});
myDataProcessor.sendData();
}

I am trying to rebuild the grid structure in my dataprocessors update page. Say my grid has 4 rows initially when the page loads with ids as folows:

1
2
3
4

Now the user adds two rows and deletes one row so now the structure looks as follows and the order in which the rows are sent back to the server are in the parenthesis:

1
2
5------------Inserted (1st)
3------------------Deleted (3rd)
4
6------------Inserted (2nd)

Now since i want to send all the rows back to the server and build the structure again i am chanaging the native_editor status to updated and now it looks as follows:

1------------------Updated (4th)
2------------------Updated(5th)
5------------Inserted (1st)
3------------------Deleted (3rd)
4------------------Updated(6th)
6------------Inserted (2nd)

So the oder in which the rows are sent back is 5,6,3,1,2,4. But i want the dataprocessor to send the rows as it is so my required row order to build my structure back is 1,2,5,3,4,6. Is there any way i can achieve this functionality??


Answer posted by Support on Aug 07, 2008 10:06
>>Is there any way i can achieve this functionality??
Dataprocessor sends the rows in same order as they was marked updated|inserted|deleted
It hard to change such behaviour, but you can add one more param to specify row index. 


mygrid.forEachRow(function(id){ 
    if( status != 'deleted' && status != 'inserted') 
    { 
        myDataProcessor.setUpdated(id,true); 
    }
}); 
for (var i=0; i<mygrid.getRowsNum(); i++)
     mygrid.setUserData(mygrid.getRowId(i),"row_index",i)
myDataProcessor.sendData();