I am using the dhtmlxgrid_form.js to send a grid to PHP using the $_POST variables and I have encountered a problem.
I have a grid with three lines. I move the third line up to the the top of the grid. Now the index of the third line is 0. When I click on submit and recover the $_POST variables, the third line which has an index of 0 still shows up as the third line in the $_POST.
So imagine I have a table with 3 rows
Row 1 Test 1
Row 2 Test 2
Row 3 Test 3
I move the third row up to the top. Now I have
Row 3 Test 3
Row 1 Test 1
Row 2 Test 2
When the data is sent to PHP, I get the data back the order in which it was originally created.
Row 1 Test 1
Row 2 Test 2
Row 3 Test 3
Is there way to send the data to PHP based on each row’s index and not its ID? Or is there a way to change the ID of the row to match the index every time it is moved
Actually there was not any special meaning in order of data inside POST sending, it just a not-expected side effect that data sent in same order as rows loaded in grid.
dhtmlxgrid_form.js , line 156
this.forEachRow(function(id){
this._createInputRow(this.rowsAr[id]);
})
can be replaced with
for (var i=0; i<this.rowsBuffer.length; i++)
this._createInputRow(this.rowsBuffer[i]);
It will change behavior of “send all” mode, so order of parameters will be equal to order of rows in grid.
this.forEachRow(function(id){
this._createInputRow(this.rowsAr[id]);
})
was actually in the dhtmlxgrid_form.js and not in the dhtmlxgrid.js. Your solution did work however
Craig