Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Frank on Aug 27, 2009 07:08
open dhtmlx forum
grid's column sort function

if xml file include "<head>" tag, "setColSorting" function not working
it not include it, then working fine

var mygrid = new dhtmlXGridObject('mygrid_container');
mygrid.setImagePath("../dhtmlxSuite/dhtmlxGrid/codebase/imgs/");
mygrid.setHeader("Department,Name,Email,Title");

mygrid.setColumnIds("dept,name,email,pos")
mygrid.setInitWidths("150,*,250,150");

mygrid.setColAlign("left,left,left,left")
mygrid.setSkin("modern");
mygrid.setColSorting("str,str,str,str"); <----- no use
mygrid.enableEditTabOnly(1);
mygrid.preventIECaching(true);
mygrid.enableRowsHover(true,'grid_hover')
mygrid.setActive(true);
mygrid.init();
mygrid.loadXML("userInfo2.xml");

userInfo2.xml
<?xml version="1.0" encoding="utf-8"?>
<rows>
<head>
<column width="100" type="coro">Department
<option value="11">dpt1</option>
<option value="12">dpt1-1</option>
<option value="13">dpt2</option>
<option value="14">dpt2-1</option>
<option value="15">dpt-3</option>
<option value="16">dpt-31</option>
</column>
<column width="100" type="ed">name</column>
<column width="*" type="ed">Email</column>
<column width="120" type="ed">Title</column>
</head>
<row id="1">
<cell>12</cell>
<cell>frank1</cell>
<cell>aa@aa.mm</cell>
<cell>pos1</cell>
</row>
<row id="5">
<cell>12</cell>
<cell>sss</cell>
<cell>aa@ssf</cell>
<cell />
</row>
<row id="3">
<cell>13</cell>
<cell>frank2</cell>
<cell>dd@aa.vv</cell>
<cell>pos2</cell>
</row>
<row id="4">
<cell>14</cell>
<cell>frank3</cell>
<cell>cc@xx.cc</cell>
<cell />
</row>
</rows>
Answer posted on Aug 27, 2009 09:01
>>if xml file include "<head>" tag, "setColSorting" function not working
This is expected behaviour.If you have defined grid cofiguration with API and then load grid with configuration part, API's configuration will be overloaded. 
If you have <head> in your xml you can set columns sorting using "sort" attribute:
<column type="edn" width="150" sort="str" format="0.00">
Please find more information here http://dhtmlx.com/docs/products/docsExplorer/doc/dhtmlxxml/index.html#dhtmlx_xml