using xmlB format


Hi,



We are trying to load data in our grid using an xml. We have a custom xml named EmployeeData.xml format like :



<?xml version="1.0" encoding="utf-8"?>



<Employees>



<Employee ID=“xxx-xx-1234”>



<PostId>1</PostId>



<Department>IT</Department>



<EmployeeNum>xxx-xx-1234</EmployeeNum>



<EmployeeName>Ortha G. Smith</EmployeeName>



<Status>Active</Status>



<Exempt>No</Exempt>



<TempDept>



</TempDept>



<TempRate>



</TempRate>



<RegHrs>80</RegHrs>



<OTHrs>0</OTHrs>



<Other1>0</Other1>



<Other2>0</Other2>



<Earnings1>0</Earnings1>



<Earnings2>0</Earnings2>



<Earnings3>0</Earnings3>



</Employee>



</Employees>



 



in our jsp code where we are making the grid, we have written the following code to match the above format:



function doInitGrid(){



mygrid = new dhtmlXGridObject(‘mygrid_container’);



mygrid.setImagePath(“imgs/”);



mygrid.setHeader(“PostId,Department,EmployeeNum,EmployeeName,Status,Exempt,TempDept,TempRate,RegHrs,OTHrs,Other1,Other2,Earnings1,Earnings2,Earnings3”);


mygrid.setInitWidths(",,,,,,,,,,,,,,*");



mygrid.setColAlign(“center,center,center,center,center,center,center,center,center,center,center,center,center,center,center”);



mygrid.setSkin(“light”);



mygrid.setColSorting(“na,str,str,str,str,na,na,na,na,na,na,na,na,na,na”);



mygrid.setColTypes(“ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed”);



mygrid.setColumnIds(“PostId,Department,EmployeeNum,EmployeeName,Status,Exempt,TempDept,TempRate,RegHrs,OTHrs,Other1,Other2,Earnings1,Earnings2,Earnings3”);



mygrid.enableKeyboardSupport(true);


mygrid.enableSmartRendering(true,10);


mygrid.init();



mygrid.loadXML(“EmployeeData.xml”,“xmlB”);



 



But this is not working. We have also included the js file u have attached in this post. Kindly let us know what need to be done.



Thanks in advance.



 

You need to define used tag names

grid.xml.top="Employees"
grid.xml.row="Employee"

mygrid.loadXML(“EmployeeData.xml”,“xmlB”);


Thanks a lot :slight_smile: it works!