We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to keep the child grid open in initial rendering

Platform: jQuery |
Control: ejGrid

 Initially the child grid or details row in grid will be in collapse state. The Grid uses lazy rendering technique to render the child grid or details row and hence they will rendered only after clicking the expand button at the left most column of the grid.


To keep the child grid/ details row open in the initial rendering itself, we need to invoke the expandAll grid`s public function in the dataBound event.


The dataBound event is the suitable event to call the expandAll method at initial rendering. For need to call the expandAll method in the actionComplete event.


The following code example demonstrates how to open the child grid or details row in the initial rendering and also after every grid action.



<div id="Grid"></div>


<script type="text/javascript">
        $(function () {
                dataSource: new ej.DataManager(window.employeeView),       
                allowPaging: true,
                pageSettings: { pageSize: 3 },
                columns: [
                          { field: "EmployeeID", headerText: 'Employee ID', textAlign: ej.TextAlign.Right, width: 75 },
                          { field: "FirstName", headerText: 'First Name', width: 100 },
                          { field: "Title", headerText: 'Title',  width: 120, visible: true },
                          { field: "City", headerText: 'City', width: 100 }   
                childGrid: {
                    dataSource: window.ordersView,
                    queryString: "EmployeeID",
                    columns: [
                                { field: "OrderID", isPrimaryKey: true, headerText: "Order ID", width: 80, textAlign: ej.TextAlign.Right },
                                { field: "CustomerID", headerText: 'Customer ID', width: 80, textAlign: ej.TextAlign.Left },
                                { field: "Freight", headerText: 'Freight', width: 90, textAlign: ej.TextAlign.Right }
                dataBound: "OnDataBound",
                actionComplete: "OnActionComplete"




            .PageSettings(p => p.PageSize(3))
            .Columns(col =>
                col.Field(p => p.EmployeeID).HeaderText("Employee ID").Add();
                col.Field(p => p.FirstName).HeaderText("First Name").TextAlign(TextAlign.Left).Add();
                col.Field(p => p.Title).HeaderText("Title").Add();
                col.Field(p => p.City).HeaderText("City").Add();
                child =>
                      .Columns(col =>
                            col.Field(p => p.OrderID).HeaderText("Order ID").Width(80).TextAlign(TextAlign.Right).Add();
                            col.Field(p => p.CustomerID).HeaderText("Customer ID").Width(80).Add();
                            col.Field(p => p.Freight).HeaderText("Freight").Width(90).TextAlign(TextAlign.Right).Add();
            .ClientSideEvents(evt => evt.DataBound("OnDataBound")





As the ASP.Net Grid don’t support hierarchical bindings, we have used the details template to depict the usage of the expandAll method.


<script id="GridDetail" type="text/x-jsrender">
        <div id="detailGrid{{:EmployeeID}}" class="e-childgrid"></div>
<ej:Grid ID="Grid" runat="server" AllowPaging="true" DetailsTemplate="#GridDetail">            
            <PageSettings PageSize="3" />
                <ej:Column Field="EmployeeID" HeaderText="Employee ID" TextAlign="Right" Width="75"/>
                <ej:Column Field="FirstName" HeaderText="First Name" Width="100"/>
                <ej:Column Field="Title" HeaderText="Last Name" Width="120"/>
                <ej:Column Field="City" HeaderText="City" Width="100"/>
            <ClientSideEvents DetailsDataBound="detailGridData" DataBound="OnDataBound" ActionComplete="OnActionComplete" />



function detailGridData(e) {
            var filteredData = e.data["EmployeeID"];           
            var data = ej.DataManager(window.ordersView).executeLocal(ej.Query().where("EmployeeID", "equal", parseInt(filteredData)));
                dataSource: data,
                columns: [
                        { field: "OrderID", isPrimaryKey: true, headerText: "Order ID", width: 80, textAlign: ej.TextAlign.Right },
                        { field: "CustomerID", headerText: 'Customer ID', width: 80 },                        
      { field: "Freight", headerText: 'Freight', width: 90, textAlign: ej.TextAlign.Right }
            e.detailsElement.css("display", "");



The expandAll method will be invoked in the dataBound and the actionComplete event as follows.


function OnDataBound(args) {
function OnActionComplete(args) {
    if (args.requestType == "paging")



The below screenshot is displayed as the result of the above code examples.


Hierarchy Grid


Open child grid/details rows initially using expandAll method.

Expanded Child Grid


You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile