Updating Andreas's expanded grid example for V2
Hi,
I'm trying to get the excellent example of an expanded grid provided by Andreas at the URI listed below to work in version 2.
http://www.terriblecow.com/awc/ex_row/dyntable.html
It seems to work fine however, I have one problem. When I click on a row to expand it, the data in the master grid row that I click on is vertically aligned in the middle instead of at the top. The effect is that I cannot properly see the data behind the newly created child grid. In Andreas's example the row that is clicked keeps it's data 'top' aligned in the row.
I've tried changing the vertical-align style of the RowTemplate but no luck.
Anyone got ideas? Andreas, can you help please?
Thanks in advance.
BT
December 19,
You have to change the alignment of the text span inside the cell template:
.aw-item-text {
vertical-align: top;
}
Alex (ActiveWidgets)
December 19,
Hi,
Can anyone post an example of an expanded grid in v2 beta 2?
Thanks in advance,
Kalyana Sundaram S
January 19,
Hi,
Apologies for the typo, I meant 'an expanded grid in v2 beta 3'...
Regards,
Kalyana Sundaram S
January 19,
BT,
Could you share how you got this working. I'm trying, but no success.
Jim D.
February 1,
Hey,
Sorry for the late reply. Haven't been on this forum for a while and just noticed your request now.
I've attached some code, hope it helps you.
Sorry about the length of the post....wanted to be clear!
BT
this.onRowClicked = function(event, index) {
var row = this.getRowTemplate(index);
if (isRowExpanded(index)) {
this.collapseRow(row.getId(), index);
} else {
this.expandRow(row.getId(), index);
}
};
this.expandRow = function(rowid, id) {
var expandRow = Utils_v1.getDocumentElement(rowid);
if (!Utils_v1.isValidValue(expandRow)) {
return;
}
var childDiv = Utils_v1.getDocumentElement("exp_" + id);
if (!Utils_v1.isValidValue(childDiv)) {
childDiv = document.createElement("DIV");
childDiv.id = "exp_" + id;
childDiv.className = "child-grid-style";
var subGroup = "WHATEVER";
var gridId = this.getId() + "_" + subGroup + "_" + id;
var isNewGrid = false;
if (!Utils_v1.isValidValue(this.getManager().getGrid(gridId))) {
isNewGrid = true;
}
try {
this.getManager().createGrid(subGroup, gridId, childDiv.id);
} catch(e) {
return;
}
expandRow.appendChild(childDiv);
try {
this.getManager().renderGrid(gridId);
} catch(e) {
return;
}
if (isNewGrid) {
this.getManager().startDataRefresh(gridId);
setRowExpanded(id, gridId);
}
}
expandRow.style.height = "180px";
};
this.collapseRow = function(rowid, id) {
var expandedRow = Utils_v1.getDocumentElement(rowid);
if (Utils_v1.isValidValue(expandedRow)) {
expandedRow.style.height = null;
expandedRow.removeChild(Utils_v1.getDocumentElement("exp_" + id));
var gridId = this.getId() + "_" + getSubGroup() + "_" + id;
this.getManager().getGrid(gridId).stopRefreshTimer();
this.getManager().destroyGrid(gridId);
setRowCollapsed(id);
}
};
BT
February 3,
Sorry...should also have said.
When you have created your new grid object and want to draw it on screen, you set the innerHtml property of the childDiv that you created to childGrid.toString()
childDiv.innerHtml = childGrid.toString();
BT
BT
February 3,