I am using dhtmlxGrid recently, well I try to load my grid with mysql and php file. but gives me xml error incorrect. I have read several posts, but have not found the solution. I leave part of my code to see if I can lend a hand. Thanks
my grid configuration:
function doOnLoad() {
mygrid = new dhtmlXGridObject(‘gridbox’);
mygrid.setImagePath(“codebase/imgs/”);
mygrid.setHeader(“Repuesto,Descripcion,Cantidad,Stock,Seleccionar Repuesto”);
mygrid.setInitWidths(“100,250,80,80,80”);
mygrid.setColAlign(“right,left,left,right,center”);
mygrid.setColTypes(“ro,ro,ro,ro,ro”);
mygrid.getCombo(5).put(2, 2);
mygrid.setColSorting(“int,str,int,str,int”);
mygrid.setColumnColor(“white,#d5f1ff,#d5f1ff”);
mygrid.setColumnMinWidth(50, 0);
mygrid.init();
mygrid.setSkin(“dhx_skyblue”);
mygrid.loadXML(“php/ObtenerRepuestos.xml”, function() {
mygrid.attachHeader("
//set title filter field;
document.getElementById(“buscaR”).appendChild(document.getElementById(“repuesto”).childNodes[0]);
//set author fiter field;
document.getElementById(“buscaD”).appendChild(document.getElementById(“descripcion”).childNodes[0]);
// Esto es para lista desplegable opciones de busqueda por agrupacion y concidencia
/* var authFlt = document.getElementById(“buscaD”).appendChild(document.getElementById(“descripcion”).childNodes[0]);
populateSelectWithAuthors(authFlt); */
//block sorting and resize actions for second row;
mygrid.hdr.rows[2].onmousedown = mygrid.hdr.rows[2].onclick = function(e) { (e || event).cancelBubble = true;
}
mygrid.setSizes();
});
}
function filterBy() {
var tVal = document.getElementById(“buscaR”).childNodes[0].value.toLowerCase();
var aVal = document.getElementById(“buscaD”).childNodes[0].value.toLowerCase();
for (var i = 0; i < mygrid.getRowsNum(); i++) {
var tStr = mygrid.cells2(i, 0).getValue().toString().toLowerCase();
var aStr = mygrid.cells2(i, 1).getValue().toString().toLowerCase();
if ((tVal == “” || tStr.indexOf(tVal) == 0) && (aVal == “” || aStr.indexOf(aVal) == 0)){
mygrid.setRowHidden(mygrid.getRowId(i), false);
}
else{
mygrid.setRowHidden(mygrid.getRowId(i), true);
}
}
}
function populateSelectWithAuthors(selObj) {
selObj.options.add(new Option(“All Authors”, “”));
var usedAuthAr = new dhtmlxArray();
for (var i = 0; i < mygrid.getRowsNum(); i++) {
var authNm = mygrid.cells2(i, 2).getValue();
if (usedAuthAr._dhx_find(authNm) == -1) {
selObj.options.add(new Option(authNm, authNm));
usedAuthAr[usedAuthAr.length] = authNm;
}
}
}
my php file generate xml
<?php error_reporting(E_ALL ^ E_NOTICE); //Conexiones Base de Datos require_once('../common/config.php'); require_once('../common/config_dp.php'); // XML Header header("Content-type: text/xml"); //encoding may be different in your case echo('<?xml version="1.0" encoding="utf-8"?>');//start output of data
echo ‘’;
//output data from DB as XML
$sql = “SELECT * FROM producto ORDER BY id ASC”;
$res = mysql_query ($sql);
if($res){
while($row=mysql_fetch_array($res)){
//create xml tag for grid’s row
echo ("<row id=’".$row[‘id’]."’>");
print("");
print("");
print("");
print("");
print("");
print("");
}
}else{
//error occurs
echo mysql_errno().": “.mysql_error().” at “.LINE.” line in “.FILE.” file
";
}
echo ‘’;
?>