<div id="Grid"></div> <script id="GridContents" type="text"> <div id="detailGrid{{:taskID}}"> </div> </script> <script type="text/javascript"> $(function () { var projectData = [ { taskID: 1, . . . subtasks: [ { taskID: 2, duration: 5, progress: 100, priority: "Normal", approved: false }, . . . ] }, . . . }] $("#Grid").ejGrid({ dataSource: ej.DataManager(projectData), detailsTemplate: "#GridContents", detailsDataBound: "detailGridData", allowGrouping: true, columns: [ { field: "taskID", headerText: 'Task ID' }, { field: "progress", headerText: 'Progress' }, { field: "duration", headerText: 'Duration' }, { field: "priority", headerText: 'Priority' }, { field: "approved", headerText: 'Approved' } ] }); }); function detailGridData(e) { var filteredData = e.data["subtasks"], id = e.data["taskID"]; e.detailsElement.find("#detailGrid" + id).ejGrid({ dataSource: filteredData, columns: [ { field: "taskID", headerText: 'Sub Task ID' }, { field: "progress", headerText: 'Sub Progress' }, { field: "duration", headerText: 'Sub Duration' }, { field: "priority", headerText: 'Sub Priority' }, { field: "approved", headerText: 'Approved' } ] }); } </script> |
<ej-grid id="FlatGrid" datasource="@ViewBag.parent" details-template="#tabGridContents" details-data-bound="detailGridData" allow-paging="true"> <e-columns> <e-column field="EmployeeID" header-text="Employee ID" is-primary-key="true" allow-editing="false" text-align="Left" width="75"> </e-column> <e-column field="FirstName" header-text="FirstName"></e-column> <e-column field="LastName" header-text="LastName"></e-column> </e-columns> </ej-grid> <script type="text/javascript"> function detailGridData(e) { var filteredData = e.data["EmployeeID"]; // the datasource "window.ordersView" is referred from jsondata.min.js var data = ej.DataManager(window.ordersView).executeLocal(ej.Query().where("EmployeeID", "equal", parseInt(filteredData), true)); e.detailsElement.find("#detailGrid").ejGrid({ dataSource: data, allowSelection: false, allowPaging:true, columns: [ { field: "OrderID", key: true, headerText: "Order ID", width: 80, textAlign: ej.TextAlign.Right }, { field: "CustomerID", headerText: 'Customer ID', width: 80, textAlign: ej.TextAlign.Left }, { field: "CompanyName", headerText: 'Company Name', width: 120, textAlign: ej.TextAlign.Left }, { field: "ShipCity", headerText: 'City', width: 120, textAlign: ej.TextAlign.Left } ] }); } </script> <script id="tabGridContents" type="text/x-jsrender"> <div class="tabcontrol" id="Test"> <div id="detailGrid"> </div> </div> </script> |
This helped me with the Grid as well. Thank you so much.