Categories | Question details Back To List | ||
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 <script> mygrid = new dhtmlXGridObject('mygrid_container'); mygrid.attachEvent("onXLS",function(){document.getElementById("my_message").style.display="block";}) mygrid.attachEvent("onXLE",function(){document.getElementById("my_message").style.display="none";}) mygrid.setImagePath("assets/dhtmlxGrid/dhtmlxGrid/codebase/imgs/"); mygrid.setHeader("Product ID,Name, Ref"); mygrid.setInitWidths("100,400,190"); mygrid.setColTypes("ro,ro,ro"); //use the database mygrid.setColSorting("connector","connector","connector"); mygrid.setColAlign("left,left,left"); mygrid.enableCollSpan(true); mygrid.setSkin("modern"); mygrid.init(); mygrid.enablePaging(true,20,10,"pagingArea",true,"infoArea"); mygrid.setPagingSkin("bricks"); mygrid.loadXML("xml/testXML.php"); </script> **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. Answer posted by Support on Apr 01, 2009 05:19 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' Answer posted by Thanks for your help. The strange part was a typo in my question. I'll try using the logging. Thanks again. on Apr 01, 2009 06:16 Answer posted by Paul Dunn on Apr 01, 2009 07:25 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. Answer posted by Support on Apr 01, 2009 09:47 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 Answer posted by Paul Dunn on Apr 01, 2009 13:04 Excellent! - Thanks again for your help. |