|
let initialFlag = true;
let grid: Grid = new Grid({
dataSource: employeeData,
allowSorting: true,
allowPaging: true,
detailDataBound: detailDataBound,
dataBound: dataBound,
columns: [
{
field: "EmployeeID",
headerText: "Employee ID",
textAlign: "Right",
width: 125
},
{ field: "FirstName", headerText: "Name", width: 125 },
{ field: "Title", headerText: "Title", width: 180 },
{ field: "City", headerText: "City", width: 110 },
{ field: "Country", headerText: "Country", width: 110 }
],
pageSettings: { pageSize: 5 },
childGrid: {
dataSource: dataManger,
queryString: "EmployeeID",
allowPaging: true,
columns: [
{
field: "OrderID",
headerText: "Order ID",
textAlign: "Right",
width: 120
},
{ field: "ShipCity", headerText: "Ship City", width: 120 },
{ field: "Freight", headerText: "Freight", width: 120 },
{ field: "ShipName", headerText: "Ship Name", width: 150 }
]
}
});
grid.appendTo("#Grid");
function detailDataBound(e) {
var Index = e.detailElement.parentElement.previousElementSibling.ariaRowIndex;
}
function dataBound() {
if (initialFlag) {
this.on("detail-state-change", detailChange, this);
initialFlag = false;
}
}
function detailChange(args: any) {
var collapseIndex = args.detailElement.closest("tr").ariaRowIndex;
alert(collapseIndex);
} |