Persist Kendo Grid Client Side filter

1 Answer 15 Views
Filter Grid
Wilhelm
Top achievements
Rank 1
Wilhelm asked on 21 Dec 2021, 09:24 PM

Good day I am using a Kendo Grid on one of my applications. The Grid is defined like below. Editing of data is done via a popup that started from the _EditRoute action. Data for the grid is bound serverside via _SelectRouteData but users can apply their own filter to the Data via the header column since we have .Filterable() enabled on the Grid. Currently the state of that filter is lost when context passes back to the main grid after an update on the the Popup Screen as we call grid.rebind() in Javascript to refresh data in the Grid Post update.

Is there an easy way to persist the state of the ClientSide filter?

I have tried saving and reapplying the filter in Javascript like this

var filter = grid.dataSource.filter(); grid.rebind(); grid.dataSource.filter(filter);

but this still loses the filter after grid.rebind()


Any help would be greatly appreciated.

Best Regard
Wilhelm Erxleben

@(Html.Telerik().Grid(Model)
                                .Name("RouteManagement")
                                .DataKeys(keys => keys.Add(r => r.RouteID))
                                .ColumnContextMenu()
                                .Columns(columns =>
                                {
                                    columns.Bound(r => r.RouteID).Title("Route ID").Width(40).Hidden(true).IncludeInContextMenu(false);
                                    columns.Command(commands =>
                                        commands.Custom("editRoute")
                                            .Text("Edit Route")
                                            .ButtonType(GridButtonType.Image)
                                            .DataRouteValues(route => route.Add(r => r.RouteID).RouteKey("routeId"))
                                            .Ajax(true)
                                            .Action("_EditRoute", "RouteData")

                                    ).Width(50).IncludeInContextMenu(false);

                                    columns.Bound(r => r.AccountNo).Title("Account No")
                                    columns.Bound(r => r.ConsumerNo).Title("Consumer No")
                                    columns.Bound(r => r.DivertCodes).Width(105);


                                })
                                .DataBinding(dataBinding => dataBinding.Ajax()
                                    .Select("_SelectRouteData", "RouteData"))
                                .Sortable()
                                .Selectable()
                                .Filterable()
                                .Resizable(resizing => resizing.Columns(true))

                                .Scrollable(scroll => scroll.Height("410px"))
                                .ClientEvents(events => events
                                                .OnLoad("onLoad").OnDataBinding("BindValues")
                                                .OnRowSelect("onRouteRowSelected")
                                                .OnRowDataBound("onRouteRowDataBound")
                                                .OnComplete("onRouteComplete"))
        )




1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 24 Dec 2021, 06:44 AM

Hello Wilhelm,

 

Thank you for writing to us.

The grid provides a build-in way to save its entire state:
https://demos.telerik.com/aspnet-mvc/grid/persist-state

If you want to avoid the buttons and let this saving happen automatically, this is also possible:
https://docs.telerik.com/kendo-ui/knowledge-base/grid-automatically-persist-state

With template columns and custom filters things a bit different, but still possible:
https://docs.telerik.com/kendo-ui/knowledge-base/grid-persist-customized-filter

We also provide the Filter component which is a separate widget by itself and can prove helpful to you:
https://demos.telerik.com/aspnet-mvc/filter/persist-state

Can you check these options and let me know what you thing? Would that persisting will be suitable for your case?

Let me know your opinion.

 

Regards,
Eyup
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Filter Grid
Asked by
Wilhelm
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or