Sort read only tables

Hi,

I am using the evaluation version and checking if I can convert the existing tables in my project to grids. I want the cells to be readonly and every column should be sortable too.

Given below is the code I have used.
var mygrid= new dhtmlXGridFromTable(‘scrollTableDhtmlxGrid’);
mygrid.setInitWidthsP(“11,11,10,11,12,10,11,12,12”);
mygrid.setColTypes(“ro”,“ro”,“ro”,“ro”,“ro”,“ro”,“ro”,“ro”,“ro”);
mygrid.setColSorting(“date”,“int”,“int”,“text”,“text”,“text”,“text”,“text”,“text”);
mygrid.setColAlign(“center,right,right,center,center,center,center,left,left”);
mygrid.enableAutoWidth(true);
mygrid.enableRowsHover(true,“grid_hover”);
mygrid.enableAlterCss(“even_row”,“odd_row”);

Sorting works if I dont use setColTypes and setColSorting. If I specify these, it doesnt work. Also, if I dont specity any colType, the cell is editable and when I double click it, the entire div is displayed and not just the value.

Any help is appreciated. I am trying to check if I can use the grid to implement what we currently have and then order the professional version.

Thanks in advance!

First row in your table will be recognized as grid header. So you can add “width”, “sort” and “type” parameters to cell from first row:

<table class="dhtmlxGrid"> <tr> <td width="150" align="left">Column 1</td> <td type="co" sort="str">Column 2</td> <td type="edn" format="0,000.00">Column 3</td> <td>Column 4</td> </tr>

Please find complete tutorial here docs.dhtmlx.com/doku.php?id=dhtm … _from_html

Thank you for the really quick reply!

The sorting works if the cell type is ro and sort is str.
However, if cell type is ron and sort is int, there is a script error in dhtmlxgridcell.js

Cant I specify the cell type as ron. I have certain integer values in the table which should also be sorted.

Also, is it possible to disable sorting for certain columns alone? If I dont specify anything, it is taken as text and sorted.

Also, is it possible to exclude a certain row for sorting. The final row of my table would contain the total value. I do not want this to be included as a part of the sorting. Is this possible?

Thanks in advance!

However, if cell type is ron and sort is int, there is a script error in dhtmlxgridcell.js
Can you provide text of the error?
Also please provide example of your grid initialization.

Also, is it possible to disable sorting for certain columns alone?
You can use “na” sorting type

Also, is it possible to exclude a certain row for sorting.
Not, it’s not possible

The final row of my table would contain the total value. I do not want this to be included as a part of the sorting. Is this possible?
You can use grid footer. You can attach footer the grid with attachFooter() method.
Please find more information here docs.dhtmlx.com/doku.php?id=dhtmlxgrid:header&s[]=footer
and example here dhtmlx.com/docs/products/dht … ooter.html

The script error that I was getting is ‘_aplNFb’ not found. But I dont get that now. I guess it was some problem in the way I was calling it.
But still, the sorting doesn’t work properly for me.

doInitGridTable1(); function doInitGridTable1(){ var mygridEg= new dhtmlXGridFromTable('myTable'); mygridEg.setInitWidths("100,200,200,200,100,100,110,120,120"); mygridEg.setImagePath("/StandardsWeb/includes/dhtmlxGrid/codebase/imgs/"); mygridEg.setColAlign("center,right,right,center,center,center,center,left,left"); mygridEg.enableRowsHover(true,"grid_hover"); mygridEg.enableAlterCss("even_row","odd_row"); mygridEg.setSkin("merlin"); } function doOnBeforeInit(){ mygrid = new dhtmlXGridFromTable('myTable'); mygrid.setInitWidths("100,200,200,200,100,100,110,120,120"); mygrid.setImagePath("/StandardsWeb/includes/dhtmlxGrid/codebase/imgs/"); mygrid.setColAlign("center,right,right,center,center,center,center,left,left"); mygrid.enableRowsHover(true,"grid_hover"); mygrid.enableAlterCss("even_row","odd_row"); mygrid.setSkin("merlin"); myTable.splitAt("1"); } I have the script defined after the table. Now, if I click on Column2 or Column3, nothing happens. It is not sorted. Also please note that when I split the grid when trying to freeze one column, the part on the left side of the grid has the default skin. As suggested in the other query, I tried to set the skin before splitting, but that throws a script error in dhtmlxgrid_start.js. Error is in line 11 --> 'obj is null'. Also, please note that when I try to initialize mygrid outside the function, I am not able use it in doOnBeforeInit() because this function is called before the initialization. If I have it in doOnBeforeInit(), the initialization is called for every row in the table and I have multiple empty grids in the page. Please let me know if I am doing something wrong. Also, I think there is a spelling mistake in dhtmlx_start.js - line 13. The method is windowf.enableAutoHeigth(true). I am assuming it should be windowf.enableAutoHeight(true)
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9