Articles in this section
Category / Section

How to maintain custom query at enablePersistance?

1 min read

Problem:

The Grid does not maintain the query params after page load even when enablePersistence is set to true. This is because the Grid refreshes its query params for every page load.

Solution:

You can maintain the custom query params by resetting the addParams method in the actionBegin client-side event.

JS

$("#OrdersGrid ").ejGrid({
        // The datasource "window.gridData" is referred from jsondata.min.js.
        dataSource: window.gridData,        
        actionBegin: "onActionBegin",
. . . .
});

 

MVC

@(Html.EJ().Grid<object>("OrdersGrid ")               
         .ClientSideEvents(eve => eve.ActionBegin("onActionBegin"))
         ----------
         ----------
) 

 

ASP

<ej:Grid ID="OrdersGrid" runat="server">
   <ClientSideEvents ActionBegin="onActionBegin" />
</ej:Grid>

 

JS Code for actionBegin event function

<script type="text/javascript">    
    function onActionBegin(args) {        
        this.model.query.addParams('$filter', 'EmployeeID eq 1');
    }</script> 

 

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