How grid data can be sent back to server side, i.e. behind the scenes, after the grid has been loaded. Actually, the onXLE event has a doAfterXMLLoad method which processes & modifies the data after xml is received from server and before data is shown to the user.
What I want is to send the modified xml data back to server, in order to save in db i.e. after doAfterXMLLoad method processes/modifies the data or it could be sent after it is shown to the user without any user action.
Please let me know if there is any way of doing it.
Thanks for your response, however I am not able to figure out how will dataprocessor component be useful except one way, i.e. after the grid is loaded, doAfterXmlLoad method performs math calculations and grid is shown to the user, the following code will have to be included after doAfterXmlLoad is executed :-
function sendData() {
var rows = mygrid.getRowsNum();
for (var i = 0; i < rows; i++) {
myDataProcessor.setUpdated(i,true); //set all rows as updated
}
myDataProcessor.sendData(); // send data to server
for (var i = 0; i < rows; i++) {
myDataProcessor.setUpdated(i,true); //set all rows as normal
}
}
As the grid loads around 1000 rows at once, so I was looking around for any other way which could be more efficient than above. So I found the below code:-
var xml=mygrid.serialize();
dhtmlxAjax.post("/apb/APBSave.do", "xml="+xml);//sends the grid xml back to server
The above code worked fine, however the complete grid xml string was not sent to server. After analyzing it looks like the serialize() method failed at a cell which has text with special characters, such as ‘&, %’ etc.
Please let me know how can dhtmlxAjax.post can be used in a correct way or if there is any other way with which I can send data to server after doAfterXmlLoad method is executed.
function sendData() {
var rows = mygrid.getRowsNum();
for (var i = 0; i < rows; i++) {
myDataProcessor.setUpdated(i,true); //set all rows as updated
}
myDataProcessor.sendData(); // send data to server
for (var i = 0; i < rows; i++) {
myDataProcessor.setUpdated(i,false); //set all rows as normal
}
}
In addition, I found this post http://forum.dhtmlx.com/viewtopic.php?f=2&t=1030. I thought the first link i.e. given for “a) use grid serialization - which generates xml description in same format as was used for data loading” could be useful, however none of the links worked.
Thanks Sematik for replying. I was away for couple of days, however I tried your suggestion after returning and still I can see the complete xml is not being sent to server even the data, for some columns, is being surrounded by tag.
So i implemented the old way for sending the data back to server after grid is loaded, i.e.
[code]
function sendData() {
var rows = mygrid.getRowsNum();
for (var i = 0; i < rows; i++) {
myDataProcessor.setUpdated(i,true); //set all rows as updated
}
myDataProcessor.sendData(); // send data to server
for (var i = 0; i < rows; i++) {
myDataProcessor.setUpdated(i,false); //set all rows as normal
}
}[/code]
Will try and update this post if I can implement a better way of sending data back to server on grid load.
Thanks,
Sam
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan