When i draw the sub grid ,then draw sub grid again.
it will draw a gird lost the sub, it seem some data will cache the grid data ,not draw again
when switch with different data , the grid not lost sub
var value = subRowCell.getValue(); the value is ‘’ " not a object.
somebody meet this issue?
code:
[code]drawGrid: function(rowsData) {
// this.hideLoadingMsg();
var self = this;
var viewType = this.viewType;
var $body = this.tableEl;
if(!rowsData){
rowsData = tableMockData[viewType];
}
var treeData = rowsData;
if (this.grid) {
this.grid.clearConfigCookie();
this.grid.clearAll();
this.grid.destructor();
this.grid = null;
$body.empty();
}
var mygrid = this.grid = new dhtmlXGridObject();
mygrid.imgURL = dhtmlxLoader.getImgURL();
mygrid.attachToObject($body.get(0));
mygrid.setHeader(",strategyName");
mygrid.setNoHeader(true);
mygrid.setColTypes("sub_row_grid,ro");
mygrid.setColAlign("left");
var width = (viewType == 'snapshot')?18*100:16*100;
mygrid.setInitWidths("30,"+width);
mygrid.enableAutoHeight(true);
mygrid.enableAutoWidth(true);
mygrid.init();
mygrid.setSkin("mr");
mygrid.attachEvent("onSubGridCreated", function(subgrid, id, index, data) {
var config = self.getSubGridConfig();
var cfgAttr = dhtmlxLoader.buildConfigArray(config);
subgrid.setHeader(cfgAttr.name.join(","), null, cfgAttr.style);
subgrid.setInitWidths(cfgAttr.width.join(","));
subgrid.setColTypes(cfgAttr.type.join(","));
subgrid.setColAlign(cfgAttr.align.join(","));
subgrid.enableResizing(cfgAttr.resize.join(","));
subgrid.enableAutoHeight(true);
subgrid.enableAutoWidth(true);
subgrid.init();
GlobalizationUtil.setGridDateFormat(subgrid, "%Y-%m-%d");
GlobalizationUtil.setGridNumberFormat(subgrid, cfgAttr.number, true);
subgrid.callEvent("onGridReconstructed", []);
subgrid.parse(data, "json");
return false; // block default behavior
});
mygrid.attachEvent("onSubRowOpen", function(id, state) {
var row = mygrid.getRowById(id);
if (state) {
row.className = "opened-row";
} else {
row.className = "closed-row";
}
});
mygrid.parse(treeData, "json");
this.openGridFirstItem();
},
openGridFirstItem: function() {
var grid = this.grid;
var firstRowId = grid.getRowId(0);
var subRowColIndex = 0;
var subRowCell = grid.cellById(firstRowId, subRowColIndex);
if (subRowCell && subRowCell.open) {
var value = subRowCell.getValue();
if(value !== ""){
subRowCell.open();
}
}
}[/code]
data:{
"rows": [{
"id": "STUSA04BFW",
"data": [{
"value": {
"id": null,
"data": null,
"rows": [{
"id": "F000002H3R",
"data": ["Schroder BRICs Feeder Equity A",
"Open-End Fund",
"KOR",
"55.1",
"55.2",
"55.3",
"55.4",
"55.5",
"55.6",
"55.7",
"55.8",
"55.9",
"55.11",
"STUSA057FF",
"FSUSA09N66",
"F000002H3R"],
"rows": null,
"class": "mr-subgrid-row",
"style": null
},
{
"id": "F00000M826",
"data": ["Schroder BRICs RP Balanced Fdr Bd Bal E",
"Open-End Fund",
"KOR",
"55.1",
"55.2",
"55.3",
"55.4",
"55.5",
"55.6",
"55.7",
"55.8",
"55.9",
"55.11",
"STUSA057FF",
"FSUSA0BCEV",
"F00000M826"],
"rows": null,
"class": "mr-subgrid-row",
"style": null
},
{
"id": "F000002H49",
"data": ["Schroder BRICs Balanced Feeder Bd Bal A",
"Open-End Fund",
"KOR",
"55.1",
"55.2",
"55.3",
"55.4",
"55.5",
"55.6",
"55.7",
"55.8",
"55.9",
"55.11",
"STUSA057FF",
"FSUSA09N64",
"F000002H49"],
"rows": null,
"class": "mr-subgrid-row",
"style": null
}],
"class": null,
"style": null
},
"type": "sub_row_grid",
"class": null,
"style": null
},
"AllianceBernstein Global Real Estate"],
"rows": null,
"class": "mr-grid-row",
"style": null
},
{
"id": "STUSA054Y4",
"data": [{
"value": {
"id": null,
"data": null,
"rows": [{
"id": "F000002H5Z",
"data": ["Schroder BRICs Feeder Equity E1",
"Open-End Fund",
"KOR",
"55.1",
"55.2",
"55.3",
"55.4",
"55.5",
"55.6",
"55.7",
"55.8",
"55.9",
"55.11",
"STUSA057FF",
"FSUSA09N65",
"F000002H5Z"],
"rows": null,
"class": "mr-subgrid-row",
"style": null
}],
"class": null,
"style": null
},
"type": "sub_row_grid",
"class": null,
"style": null
},
"Federated National Tax-Free Money Market"],
"rows": null,
"class": "mr-grid-row",
"style": null
}]
}