Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by David on Jul 22, 2008 11:35
open dhtmlx forum
Using xmlB, define column order

I'm using a custom.xml w/ xmlB to load into my grid. The custom.xml is shown below. Note the User attributes, "firstName, id, initials, and lastName" tags are in alphabetical order. I can't change the ordering of the xml because the xml is generated from a webservice. (given the webservice framework that i'm using)

<company>
<user>
<firstName>Bob</firstName>
<id>234</id>
<initials>BBB</initials>
<lastName>Roberts</lastName>
</user>
<user>
<firstName>Jim</firstName>
<id>988</id>
<initials>JJJ</initials>
<lastName>James</lastName>
</user>
</company>

The grid will display...
Bob,234,BBB,Roberts
Jim,988,JJJ,James

How can I control the column ordering such that I want the grid to display
234,BBB,Bob,Roberts
988,JJJ,Jim,James

I tried "mygrid.setColumnIds("id,initials,firstName,lastName");" and that doesn't seem to work ? ? ?

Thx in advance
Answer posted by Support on Jul 23, 2008 01:41
Problem confirmed and fixed, please use attached js file instead of original one - with it, order of columns will be equal to the order of column IDs
Attachments (1)
Answer posted by vartika vaish on Jul 23, 2008 22:09

Hi David and the support team,

We are trying to do exactly the same thing as david mentioned. 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.

 

Answer posted by Support on Jul 24, 2008 02:11

You need to defined which tag used as top element , and which one define rows

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

mygrid.loadXML("EmployeeData.xml","xmlB");