cuser
July 23, 2012, 4:34am
#1
Hi,
i want to use a subgrid , but i can’t get it to work. here is sample code. Can anyone help me to say whats wrong. many thanks
in index.php i loaded
dhtmlxGrid/codebase/excells/dhtmlxgrid_excell_sub_row.js
later on in this file i have:
mygrid = new dhtmlXGridObject('gridbox');
mygrid.selMultiRows = true;
mygrid.enableDragAndDrop(false);
mygrid.setImagePath("/scripts/dhtmlxTreeGrid/imgs/");
mygrid.setHeader("Menu,ID");
mygrid.setInitWidths("200,50")
mygrid.setColTypes("sub_row_grid,ro,ro");
mygrid.enableAutoHeight(true);
mygrid.enableAutoWidth(true);
mygrid.attachEvent("onSubGridCreated",function(subgrid, id, ind){
subgrid.setHeader("filename");
subgrid.init();
subgrid.loadXML("connector_view2.php?id=" + rowID);
return false; // block the default subgrid logic
});
mygrid.init();
mygrid.loadXML("connector_view.php");
var myDataProcessor = new dataProcessor("connector_view.php");
myDataProcessor.setDataColumns([false,false,false,false,false]);
myDataProcessor.init(mygrid);
connector_view.php and connector_view2.php have a line as (sql is correct)
$grid->render_sql("SELECT * FROM data order by ...);
Unfortunately the issue cannot be reconstructed. Your code loads subgrid well.
Note: it is recommended to call onGridReconstructed() event after loading of data to subgrid for correct displaying:
mygrid.attachEvent("onSubGridCreated",function(subgrid, id, ind){
subgrid.setHeader("filename");
subgrid.init();
subgrid.loadXML("connector_view2.php?id=" + rowID,function(){
subgrid.callEvent("onGridReconstructed",[])
});
return false; // block the default subgrid logic
});
If issue still occurs - please provide open ticket at support.dhtmlx.com and provide a complete demo or provide a demo link where the issue can be reconstructed.
cuser
July 23, 2012, 11:21am
#4
Hi,
i did the changes. doesn’t still work .
maybe i get the wormng value for the subgrid in
mygrid.attachEvent("onSubGridCreated",function(subgrid, id, ind){
subgrid.setHeader("Titre,Fichier");
subgrid.init();
subgrid.loadXML("connector_testpod2.php?id=" + data[0],function(){subgrid.callEvent("onGridReconstructed",[])});
return false; // block the default subgrid logic
});
data[0] should be the value of the cell of the first column clicked. is this correct?
you can view the page here: reuter.schoulsteesel.net/testpod.php
Clicking on a “+” icon to expand the row throwing the following error:
ReferenceError: data is not defined
subgrid.loadXML(“connector_testpod2.php?id=” + data[0]);
Please, check what is “data” and the place where it should be added.
cuser
July 23, 2012, 1:13pm
#6
ok,
so data[0] doen’t contain the value of the cell of the first column (cell of the row clicked).
how can i get the value of the cell of the first column of the row where “+” sign is clicked
Please, try to use the following:
var val=mygrid.cells(id,ind).getValue()
cuser
July 24, 2012, 4:19am
#8
Many thanks, now everything works fine with the subgrid