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 load records in TreeGrid on demand without using data manager

Platform: jQuery |
Control: ejTreeGrid |
Published Date: September 20, 2018 |
Last Revised Date: July 20, 2021

In TreeGrid, you can load the child records of a collapsed parent record on demand with expander click action.

 

Initially all the parent records can be displayed in a collapsed state by using the enableCollapseAll property. Later, if the user wants to expand a parent record on the expander click action, its child records can be fetched from the data source and can be displayed.

 

It is also possible to load the records on demand on page switch action with paging enabled in Treegrid. With pager click action, the parent records can be fetched and can rendered in collapsed state.

 

The following code example and the screenshot explains the above described behavior.

 

export class AppComponent { 
    constructor() { 
        this.treeData =window["projectData"].slice(0,6);         
    }; 
    ngAfterContentInit() { 
        $('#pager').ejPager({ 
            pageSize: 6,             
            totalRecordsCount: window["projectData"].length, 
            pageCount: 5, 
            click: function (args) {                 
                var treeObj = $("#TreeGridControl").ejTreeGrid("instance"); 
                var prevRec = (args.currentPage - 1) * 6;                
                treeObj.setModel({ "dataSource": window["projectData"].slice(prevRec, prevRec + 6) }); 
            }, 
        }); 
    } 
} 

Loading child records on demand without data manager.

Parent records displayed in collapsed state in TreeGrid

You can find a working treegrid sample, for loading the expanded child records on demand without data manager here.

ADD COMMENT
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