Articles in this section
Category / Section

How to load records in TreeGrid on demand without using data manager

1 min read

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.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied