Categories | Question details Back To List | ||
Thank you, Forcing the cell types worked.However, while using the following code i can only see the table headers ... Thank you, Forcing the cell types worked. However, while using the following code i can only see the table headers. Can I use all the api functionality (grouping, attaching events, etc) while initializing from html table ? I am using ruby on rails. Thank you <script type ="text/javascript"> window.onload = new function(){ var mygrid = new dhtmlXGridFromTable('tblToGrid'); mygrid.setImagePath("../../images/" ); mygrid.setHeader("Division, Engine Type, Sales 06, Sales 07, Actual/Forecast 08"); mygrid.setInitWidths("100,100,100,100,100"); mygrid.setColAlign("right,left, left,left,left"); mygrid.setColTypes("ro,ro,ro,ro,ro"); mygrid.setColSorting("str,str,int,int,int"); mygrid.init(); } </script> <table id="tblToGrid" style="width:600px" imgpath="../../images/" border="1" lightnavigation="true"> <tr> <td type = "ro"> Division </td> <td type = "ro"> Engine Type</td> <td type = "ro"> Sales 06 </td> <td type = "ro"> Sales 07 </td> <td type = "ro"> Actual/Forecast 08 </td> </tr> <% @reps.each do |rep| %> <tr> <td> <%= rep.division %> </td> <td> <%= rep.engine_type1 %> </td> <td align ="right"> <%= number_to_currency(rep.actuals_06.to_f, :precision =>0) %> </td> <td align ="right"> <%= number_to_currency(rep.actuals_07.to_f, :precision =>0) %> </td> <td align ="right"> <%= number_to_currency(rep.actuals_08.to_f, :precision =>0) %> </td> </tr> <% end %> </table> Answer posted by Support on Jan 15, 2008 05:36 You need not duplicate commands and use grid.init() in case of loading from HTML, after dhtmlXGridFromTable command you already have configured and initialized grid. The correct code will look as <script type ="text/javascript"> window.onload = new function(){ var mygrid = new dhtmlXGridFromTable('tblToGrid'); // mygrid.setInitWidths("100,100,100,100,100"); -- if autoheight not work for you - need to be set as width attributes of cells in first row // mygrid.setColAlign("right,left, left,left,left"); - default align - left, if you need another - set as align attribute of cells in first row // mygrid.setColSorting("str,str,int,int,int"); - set as sort attribute of cells in first row /* any other grid related code here mygrid.attachEvent(.... mygrid.groupBy(... */ } </script> <table id="tblToGrid" style="width:600px" imgpath="../../images/" border="1" lightnavigation="true"> <tr> <td type = "ro" align ="right" width="100"> Division </td> <td type = "ro" width="100"> Engine Type</td> <td type = "ro" width="100"> Sales 06 </td> <td type = "ro" width="100"> Sales 07 </td> <td type = "ro" width="100"> Actual/Forecast 08 </td> </tr> <% @reps.each do |rep| %> <tr> <td> <%= rep.division %> </td> <td> <%= rep.engine_type1 %> </td> <td> <%= number_to_currency(rep.actuals_06.to_f, :precision =>0) %> </td> <td> <%= number_to_currency(rep.actuals_07.to_f, :precision =>0) %> </td> <td> <%= number_to_currency(rep.actuals_08.to_f, :precision =>0) %> </td> </tr> <% end %> </table> If you really need to set width|types and etc. by separate js command, it also possible but will require more complex syntax ( I can describe if it really necessary) >>I am using ruby on rails. Ruby has neat xml related functionality, so it not a problem to use default loadXML approach with ruby as well ( can provide sample if necessary ) |