I have a grid loaded with the xml that comes from database (select *… from myTbl for xml path(‘row’), root(‘rows’)…), in the event that there is no records in the database output xml is this : .
my code:
var grid = container.attachGrid();
grid.setImagePath("dhtmlxGrid/imgs/");
grid.setEditable(false);
xml = "xml/statementGrid.xml?rnd=" + new Date();
grid.loadXML(xml);
grid.enableMultiline(true);
grid.init();
grid.setSkin("dhx_skyblue");
grid.attachEvent("onXLS", function (grid_obj) { container.progressOn(); });
grid.attachEvent("onXLE", function (grid_obj, count) {
if (grid_obj.getRowsNum() > 0) {
grid_obj.selectRow(0, true, true, true);
topGridCell.progressOff();
}
});
so you see, in the case of data is present in database everything works file, but if there is no data and xml is empty(weel, almost) there is a problem.
I can probably fool it on server side and add dummy row if there is no records in database, but looking for more elegant solution. Any input would be appreciated.
Thanks in advance.