Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Chris Woow on Jul 10, 2008 03:36
open dhtmlx forum
Server Side Sorting initilized from XML with a frozen column in 1.6

Hi,

I am experiencing an issue with the latest DHTMLX Grid control when using the SplitAt() function and server side sorting. When I use the following code, the sort order on the first (frozen) column is never reversed from "asc". Removing the SplitAt() call from the XML then correctly toggles between "asc" and "des" correctly.

Can you advise on a fix for this problem, so I can use server side sorting and frozen columns at the same time?

Thanks,

Chris


function createGrid(url) {
    mygrid = new dhtmlXGridObject('table_container');
    mygrid.setImagePath("$siteroot/content/lib/dhtmlx/2/dhtmlxGrid/codebase/imgs/");
    mygrid.setSkin("platinum_manager");
    mygrid.enableRowsHover(true,'grid_hover');        
    mygrid.preventIECaching(true);
    mygrid.attachEvent("onBeforeSorting",onBeforeSort);
    mygrid.load(url);    
}

function onBeforeSort(columnIndex,grid,direct){
    mygrid.clearAll();
    mygrid.loadXML("$Url" + "&orderBy=" + columnIndex + "&direction=" + direct);
    mygrid.setSortImgState(true,columnIndex,direct);
    return false;
}

<?xml version="1.0" encoding="utf-8" ?>
<rows total_count="11" pos="0">
<head>
    <afterInit>
     <call command="splitAt">
        <param>1</param>
     </call>
     <call command="enableSmartRendering">
        <param>true</param>
        <param>50</param>
     </call>
    </afterInit>
    <column width="100" type="ro" sort="server">Domain</column>
    <column width="100" type="ro" sort="server">TLD</column>
    <column width="100" type="ro" sort="server">Country</column>
    
    ... all columns ...
    
    <column width="100" type="ro" sort="server">Portfolio sections</column>
</head>
<row id="1">

    ... table data...

</row>
</rows>
Answer posted by Support on Jul 10, 2008 04:13
The grid in split mode has next limitation - the structure of grid can't be redefined after splitAt command. Which means you can't reload configuration of such grid from XML. If loadXML, called on sorting will fetch data with head/column tags - grid will try to redefined structure , which will cause an error.

If your server side code will load only data part of grid, when server side sorting occurs - data will be correctly reordered in both parts of grid
( yout server side code must not ouput head section  if orderBy parameter specified )
Answer posted by Chris Woo on Jul 10, 2008 04:32

I can confirm that on the re-sort request I am not returning the header information.  On the server I get 2 requests from the grid and return the following XML:

1st Request: Position Start=0, Count=0, OrderBy=0, Direction=asc

<?xml version="1.0" encoding="utf-8" ?>

2nd Request: Position Star=0, Count=50, OrderBy=0, Direction=asc

<?xml version="1.0" encoding="utf-8" ?>
<rows total_count="11" pos="0">
  <row id="1">
 
   ... table data...
 
  </row>
</rows>

The direction parameter never changes to "des".  Also, is it correct to send the 1st request as empty XML?

Thanks,

Chris

 

 

Answer posted by Support on Jul 10, 2008 06:41
>>The direction parameter never changes to "des".  Also, is it correct to send the 1st request as empty XML?
It must not cause any problems ( you can send data immideatly at first request, to prevent double calls, but still it not a problem )

>>The direction parameter never changes to "des".  Also, is it correct to send the 1st request as empty XML?
Please contact us directly at support@dhtlmx.com - we will provide you an updated version of split code, which may resolve issue.