Is server-side filtering in the TreeGrid possible?

Hello

I'm trying the server-side filtering in the TreeGrid control, but it doesn't seem to work.
My TreeGrid is defined as:

@(Html.EJ().TreeGrid("Tree")
.Datasource(dsb => { dsb.URL("/Home/IndexDataSource").Adaptor(AdaptorType.UrlAdaptor); })
.AllowFiltering(true)
.IdMapping("Id")
.ParentIdMapping("ParentId")
.HasChildMapping(nameof(GridItemViewModel.IsParent))
// .EnableVirtualization(true)
.EnableLoadOnDemand(true)
.AllowPaging(true)
.PageSettings(ps => { ps.PageSize(5); }
)
.Columns(Model.Columns)
)

The same DataSource and similar setup works fine in the Grid, and server-side filtering works fine in the Grid, like this:

@(Html.EJ().Grid("Grid")
.Datasource(dsb => { dsb.URL("/Home/IndexDataSource").Adaptor(AdaptorType.UrlAdaptor); })
.Columns(Model.GridColumns)
.AllowFiltering(true)
.AllowPaging(true)
.PageSettings(new PageSettings { PageSize = 5 })

)


Is it possible to do the same with the TreeGrid?

Thanks, Tom


7 Replies

PE Punniyamoorthi Elangovan Syncfusion Team May 17, 2018 12:23 PM UTC

Hi Tomislav, 
Thank you for contacting Syncfusion support. 
We have analyzed your requirement and provided code snippets. In TreeGrid, currently we can load data source from server by using data manger with various adaptors. 
Filtering, sorting and searching operations are takes place at client side with data source loaded at TreeGrid initialization. In TreeGrid, currently there is no support to perform filtering operation at server side. 
We have planned to include this support in EJ2-TreeGrid control. As for now we don’t have support EJ2- TreeGrid control and we have already considered this is as feature. we are currently working on this control and this “EJ2-TreeGrid” will be scheduled to roll out on any of upcoming release. Until we appreciate your patience.    
Please refer this link to know more about EJ2 platform and available controls. 
Please let us know if you require further assistance on this. 
Regards, 
Punniyamoorthi. 



TT Tomislav Tustonic May 17, 2018 12:30 PM UTC

Hello

Thanks for the answer. It's not what I was hoping for, but I guess I'll have to live with it.

Bye, Tom


PE Punniyamoorthi Elangovan Syncfusion Team May 21, 2018 01:29 PM UTC

Hi Tomislav, 
As per your requirement we have achieved the server side filtering with some work around. In this work around when filtering the TreeGrid we had fetch the data source from server side with filter query and re render the TreeGrid control with new fetched data source. Please refer the below code snippet. 
@(Html.EJ().TreeGrid("container") 
          .Datasource(ds => ds.URL("Home/UrlDataSource") 
           .Adaptor(AdaptorType.UrlAdaptor)) 
           .ClientSideEvents(eve => 
             { 
                eve.ActionBegin("actionBegin"); 
            })  
            .FilterSettings(fs => fs.FilterBarMode(TreeGridFilterBarMode.OnEnter)) 
           //.. 
) 
 
 
function actionBegin(args) { 
             
            if (args.requestType == "filtering") { 
                args.cancel = true; 
                var dataManger = ej.DataManager({ url: "Home/NewUrlDataSource", adaptor: new ej.UrlAdaptor() }); 
                var treeObj = $("#container").data("ejTreeGrid"); 
                var query = ej.Query().where(ej.Predicate(args.filterCollection[0].field, ej.FilterOperators.equal, args.filterCollection[0].value, true)); 
                dataManger.executeQuery(query).done(function (e) { 
                    newValue = e.result.result; 
                    treeObj.option("dataSource", newValue); 
                }); 
            } 
        } 
public ActionResult NewUrlDataSource(DataManager dm) 
        { 
            sample s1 = new sample(); 
            IEnumerable DataSource = s1.GetSelfDataSource1(); 
            DataOperations ds = new DataOperations(); 
            List<string> str = new List<string>(); 
            if (dm.Search != null && dm.Search.Count > 0) 
            { 
                DataSource = ds.PerformSearching(DataSource, dm.Search); 
            } 
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting 
            { 
                DataSource = ds.PerformSorting(DataSource, dm.Sorted); 
            } 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
            { 
                DataSource = ds.PerformWhereFilter(DataSource, dm.Where, dm.Where[0].Operator); 
            } 
 
            var count = DataSource.Cast<BusinessObject>().Count(); 
          
            if (dm.Take != 0) 
                DataSource = ds.PerformTake(DataSource, dm.Take); 
             
            return Json(new { result = DataSource, count = count, }); 
        } 
 
But there is a limitation, when filtering the child record it will be filtered without its parent record. 
We have prepared the sample for your reference, please find the sample link below 
 
Please let us know if you require further assistance on this. 
Regards, 
Punniyamoorthi 




TT Tomislav Tustonic May 22, 2018 05:48 PM UTC

Hello
Thanks for the reply.
This seems too complicated for this feature, and I'd really like to show the full tree (found record, its children and parents).
I'll try something using Grid. It's not as nice as TreeGrid, but server-side filtering works, which is more important for my data, which is quite large, so that Internet Explorer freezes when it tries to deserialize all this data.

Thanks,
Tom



PE Punniyamoorthi Elangovan Syncfusion Team May 23, 2018 01:33 PM UTC

Hi Tomislav,  
Sorry for the inconvenience caused. 
As we said earlier, currently there is no support to perform filtering operation at server side in TreeGrid. Hence, we have considered this as feature request and have logged a report on  “Support for server side filtering in TreeGrid”.  
This feature will be implemented and included in any of our upcoming releases. 
Please let us know if you require further assistance on this. 
Regards, 
Punniyamoorthi 



TT Tomislav Tustonic May 23, 2018 02:03 PM UTC

Hello

That's OK, I'll think of something.

Bye, Tom



PE Punniyamoorthi Elangovan Syncfusion Team May 24, 2018 12:38 PM UTC

Hi Tomislav,   
Thank you for your update 
We request you to visit our website periodically for feature related updates. 
Regards, 
Punniyamoorthi 


Loader.
Up arrow icon