Categories | Question details Back To List | ||
loading data via loadXML and $_POST problem Hello, I am loading data from MySQL into the dhtmlxgrid via loadXML. When submitting the data back to MySQL via a form in PHP, I am not seeing any of the rows or columns in the $_POST variables. So even though I see the dhtmlxgrid and it is loaded with data, that data is not visible to $_POST. Craig Answer posted by Support on Jan 21, 2009 09:52 By default grid doesn't include itself into surrounding form. Can be achived by using dhtmlxgrid_form.js http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Form_integration.html#grid_art_htmlform Answer posted by Craig Efrein on Jan 22, 2009 00:04 dhtmlxgrid_form.js is included in the form. The problem is that data loaded into the grid by loadXML is invisible to the form. I load data with the following code var url1 = 'page_in_php?param=someparam'; mygridbox_rollout.loadXML(url1); When I submit the form via a SUBMIT button, none of the data loaded by loadXML shows up in the $_POST variables. If however I use the mygrid.addRow to add a line and then click on SUBMIT, the line I just added shows up in $_POST. I do not however see any of the data that was added by loadXML. Please help, Craig Answer posted by Support on Jan 22, 2009 01:50 By default grid send only changed data to server side ( that is why data created by addRow sent to server side ) If you need to send all data, just add next line to the grid's init grid.submitOnlyChanged(false); Answer posted by Craig Efrein on Jan 22, 2009 02:08 Thanks, that worked out well. While I was waiting I created a function in javascript that can add rows back using the same XML format. I'm obviously going to use your idea because it avoids having to maintain another function in javascript. function loadXMLGrid(xmlDoc, grid){ var row_string = ""; var row_id = 0; /* Now split the row into its columns */ var root = xmlDoc; for (var iNode = 0; iNode < root.childNodes.length; iNode++) { var node = root.childNodes.item(iNode); for (i = 0; i < node.childNodes.length; i++) { var sibl = node.childNodes.item(i); var len = parseInt(sibl.childNodes.length); var sibl = node.childNodes.item(i); for (x = 0; x < sibl.childNodes.length; x++) { var sibl2 = sibl.childNodes.item(x); sibl3 = sibl2.childNodes.item(0); //alert(sibl3.data) /* add each cell value to the row string */ row_string += sibl3.data + "," } /* get rid of the last comma */ row_string = row_string.substr(0,row_string.length - 1); /* if a row exists then add it */ if(row_string.length > 0){ grid.addRow((row_id+1),row_string,row_id); row_id++; } row_string = "" } } } |