Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sandeep Kath on Dec 13, 2007 21:54
open dhtmlx forum
Sorting of readonly price column in grid

Hi

We have html table with three columns and one of them is price ($0000),but sorting on price is not working ....plz help

code snippet:

<script type="text/javascript">
document.write('<table id="tbltogrid" border="1" style="width:800px;height:200px;" gridHeight="300" >');
document.write('<tr><td>Heading 1</td><td>Heading 2</td><td>Heading 3</td></tr>');
for(i=1;i<=50;i++)
document.write('<tr><td>'+Math.random()+'</td>'+'<td align="left">'+parseInt(Math.random()*1000) +'</td>'+'<td>'+Math.random()+'</td></tr>');
document.write('</table>');
</script>

<script src="js/dhtmlxcommon.js"></script>
<script src="js/dhtmlxgrid.js"></script>
<script src="js/dhtmlxgridcell.js"></script>
<script src="js/ext/dhtmlxgrid_start.js"></script>
<script>// mygrid = new dhtmlXGridObject('gridbox'); // or //mygrid = new dhtmlXGridObject(); //mygrid.attachToObject(document.body) mygrid.imgURL = "img/"; mygrid.setHeader("Column A, Column B");

mygrid = new dhtmlXGridFromTable('tbltogrid');
mygrid.enableLightMouseNavigation(true);
mygrid.setSkin("light");
mygrid.setColWidth(1,200);
mygrid.setColWidth(2,300);
mygrid.setColTypes("ro,price,ro");
mygrid.setColSorting("int,int,int");
</script>

Answer posted by Support on Dec 14, 2007 03:24
To resolve issues you need to update your code in next way

document.write('<table forceCellTypes="true" id="tbltogrid" border="1" style="width:800px;height:200px;" gridHeight="300" >');
document.write('<tr><td>Heading 1</td><td type="price">Heading 2</td><td>Heading 3</td></tr>');

This two lines clearly mark second column as "price" and force data in cell formatting.