Subgrid loading....

Hi there,
I am attempting to use subgrids within my grid, and I cannot seem to get them to work using the following code.
Nothing happens when I expand…
I NEED to use JSON from the server.

Could someone please post how I should be doing this, here is my code.

var multigrid = new dhtmlXGridObject(‘mainGridBox’);

multigrid.setImagePath("codebase/imgs/");
//multigrid.setHeader("<h1><spring:message code="view.customer.summary.daily.summary.text"/></h1>,#cspan");
//multigrid.attachHeader(["<spring:message code="view.storage.user.inventory.table.header.gashour"/>","&nbsp;"]);
multigrid.setHeader(["<spring:message code="view.storage.user.inventory.table.header.gashour"/>","&nbsp;"]);
multigrid.setInitWidths("200, 800");
multigrid.setColAlign("left,left");
multigrid.init();
multigrid.setSkin("dhx_skyblue");

var fromDateObject = dojo.byId("fromDate");
var fromDateValue = dojo.attr(fromDateObject,"value");
var storageUserObject = dojo.byId("storageUser");
var storageUserId = dojo.attr(storageUserObject,"value");
multigrid.load("secure/summary/getGasHours?gasDay="+fromDateValue+"&storageUserId="+storageUserId, "json");

multigrid.attachEvent("onSubGridCreated",function(subgrid,id,ind,data){
 	subgrid.setImagePath("codebase/imgs/");
    	subgrid.setHeader("A,B");
    	subgrid.setInitWidths("100,100");
      	subgrid.setColAlign("left,left");
      	subgrid.setSkin("dhx_skyblue");
      	subgrid.init();
      	subgrid.load(data, "json");
   		return false; 
})

I should have said that data maps to a URL which provides JSON data back for subgrid.

Grid provides onSubGridCreated event which can be used to customize sub-grid loading

grid.attachEvent(“onSubGridCreated”,function(sub,id,ind,value){
//sub - subgrid object
//value - value from XML for related cell
sub.setHeader(“ColumnA, ColumnB, ColumnC”);

sub.load(url,“json”)
return false; //block default logic
});

Hi Olga, thanks for replying, however I am doing this already, and the subgrid does not show the data.
I am at a loss as to what I am doing wrong - I have posted my code above and this doesn’t work!

Any suggestions as to what I could be doing wrong?

Thanks for your time,
Gillian

Check if you have attached dhtmlxgrid_json.js file to your page

Hi Olga,

Yes I have, the rest of the grid loads up, just not the subgrids…so confusing.

Where do you define “subgrid” eXell type? Are you able to see plus sign? Are you sure browser does not return any errors?