Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by skm on May 01, 2009 15:44
open dhtmlx forum
Groupby causing problem with int sorting

Hello Support,

I am using the following code for displaying cpu and memory stats in grid. Usually int column sorting works for me. But since I have used groupby - it's not working. what needs to change? Please advise.

        mygrid = new dhtmlXGridObject('gridbox');
        mygrid.setImagePath("dhtmlxgrid/codebase/imgs/");
        mygrid.selMultiRows = true;
        mygrid.setHeader("TX,Type,Avail,%CPU,%Mem");
        mygrid.setInitWidths("50,50,50,50,55");        
        mygrid.setColAlign("center,center,center,left,left");
        //mygrid.setColTypes("ro,colorcells");
        mygrid.setColTypes("ro,ro,ro,ro,ro");
        mygrid.setColSorting("server,server,server,server,server");
        mygrid.setColSorting("str,str,int,int,int");
        mygrid.enableRowsHover(true,'grid_hover');
        mygrid.setSkin("light");
        mygrid.init();
     mygrid.groupBy(1);    
     mygrid.setColumnHidden(1,true);
     mygrid.loadXML("getinfo.asp")

Answer posted by dhxSupport on May 04, 2009 01:21

Sorting should works well with grouping functionality. 

If grid sorted by column , by which grid grouped - order of groups changed

If grid sorted by any other columns - the order of groups not changed, but rows in groups sorted in necessary order

Answer posted on May 04, 2009 09:49

Thanks for the response.

Is it possible that the image that is included along with the number in the same cell is causing the problem? Is there any alternative method? - I need to show both the (green/red) gif and the numeric value.

Here is the snippet of asp code

if (rs("per_cpuload") >= 0) and (rs("per_cpuload") < 60) then
  Response.write("<![CDATA[   <img src='images/up.gif'> " & rs("per_cpuload") & "]]>")
elseif (rs("per_cpuload") >= 60) and (rs("per_cpuload") < 80) then
  Response.write("<![CDATA[   <img src='images/warn.gif'> " & rs("per_cpuload") & "]]>")
else
  Response.write("<![CDATA[   <img src='images/down.gif'> " & rs("per_cpuload") & "]]>")
end if

Thanks very much!

skm

Answer posted by Alex (support) on May 05, 2009 02:44

Hello,

Yes, the issue is caused by using images in the cell.

How does sorting work in grid ? - grid compares pairs of values that the getValue method returns.

getValue of ro excell (all columns in your grid have this type) returns the inner html of the cell - the image tag too. 

There are the following methods. You can choose one of them:

1) dyn excell instead of ro - down up arrows will be shown automatically: http://dhtmlx.com/docs/products/dhtmlxGrid/samples/cell_types/pro_excell_extra.html

2) creating custom excell. Please, see teh article in the package dhtmlxGrid/doc/articles/Custom_excell_creation.html

3) setting custom sorting function: dhtmlxGrid/doc/articles/Sorting_in_grid.html

Answer posted on May 05, 2009 10:23
Thanks for the quick reply.