Sorting with Grid and Connector

I am using a PRO trial version of DHTMLXgrid and DHTMLXconnector.



I am using the connector to supply the grid with data.



The data comes from a query - I want to join more tables later.

Sorting works fine on the first column, but is not available for the Name and Ref columns (see code).



The data returns fine, however I can only sort on the left column. I want to be able to sort ASC and DESC on all columns.

*** GRID CODE





**CONNECTOR CODE

$objGrid = new GridConnector($resDB);

$strSQL = “SELECT product.ProductID as ID,

product.Name,

product.Reference

FROM product

WHERE product.Reference =‘ACTIVE’”;



$objGrid->dynamic_loading(100);

$objGrid->render_sql($strSQL,“product.ID”,“ID,product.Name,product.Reference”);



How can this be done?



Thanks in advance.

The way, how both server side and client side code is correct and must not produce any problems.
The only strange place is the next

$strSQL = "SELECT product.ProductID as ID,

$objGrid->render_sql($strSQL,“product.ID”,“ID,product.Name,product.Reference”);

Not sure is it typo during question posting or typo in your code.


If issue still occurs - please try to add $objGrid->enable_log(“temp.log”,true); and check the code of SQL queries generated by connector.

By the way, it will not sort by Reference column in any case, because you have next statement in original select
WHERE product.Reference =‘ACTIVE’


I’ve tried the logging, but I don’t think it has anything to do with the SQL code.



When the grid is displayed I can only sort on one column I want to be able to sort ascending and decending on all columns.



Any advice appreciated. 

Yep, the problem was is in initialization code, somehow I missed that first time
Instead of
mygrid.setColSorting(“connector”,“connector”,“connector”);
You need to use
mygrid.setColSorting(“connector,connector,connector”); //single comma separated line


Excellent! - Thanks again for your help.