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

Rebind a saved ejGrid query before datarequest

We have a solution where the user would like to save each grid filter and sort and reuse the saved settings when they reload the page, or visit from a different computer (which rules out enablePersistance)

Currently, I am serialising the query and saving it via a web service call. This is working correctly. However when I attempt re bind the retrieved query to the grid model using the following code an error is thrown:

actionBegin: function (args) {
    args.model.query = getGridQuery(args.model.query);   // the original query object is passed in to be saved and returned on error
}

Error: DataManager - executeQuery() : A query is required to execute
    at u (http://localhost:51142/Scripts/ej/13.3.0.7/ej.web.all.min.js:10:81803)
    at Object.t.DataManager.executeQuery (http://localhost:51142/Scripts/ej/13.3.0.7/ej.web.all.min.js:10:26102)
    at Object.t.widget._initDataSource (http://localhost:51142/Scripts/ej/13.3.0.7/ej.web.all.min.js:10:1997222)
    at Object.t.widget._checkDataBinding (http://localhost:51142/Scripts/ej/13.3.0.7/ej.web.all.min.js:10:1987116)
    at Object.t.widget._init (http://localhost:51142/Scripts/ej/13.3.0.7/ej.web.all.min.js:10:1983485)
    at Object.<anonymous> (http://localhost:51142/Scripts/ej/13.3.0.7/ej.web.all.min.js:10:16506)
    at n.fn.(anonymous function) [as ejGrid] (http://localhost:51142/Scripts/ej/13.3.0.7/ej.web.all.min.js:10:17592)
    at Object.createDetailView (http://localhost:51142/Scripts/prototypes/enquiry.routing.js:267:17)
    at Object.t.widgetBase._trigger (http://localhost:51142/Scripts/ej/13.3.0.7/ej.web.all.min.js:10:10945)
    at Object.t.gridFeatures.common.expandCollapse (http://localhost:51142/Scripts/ej/13.3.0.7/ej.web.all.min.js:10:1712386)

When inspecting the query object in debug mode it looks correct and is set correctly, but the grid always throws the error. 

Does anyone have an example which shows the best way to save and reuse a query?

Thanks in advance.



2 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team May 30, 2016 01:55 PM UTC

Hi Grant, 

Thanks for using Syncfusion products. 
 
We created a sample and in this sample we used two buttons and a dropDownlist. One button is to store the state and another one is to retrieve the stored state.  
 
When we click the “Save State” button, using AJAX post will send the filterSettings and SortSettings property to server side and that will be stored into SQL data base.  
  
When we click on “Previous State” button, get the filterSettings and sortSettings Grid model from SQL data base and send it to client side using AJAX, then will update the Grid model using model values got from server-side. 
 
If the above sample does not meet your requirement or if you still want to restore Grid state using Grid Query property, then please provide us the following details. 
 
1.       In the actionBegin event you used getGridQuery method to rebind the query. So, we need the code example of an getGridQuery method. 
 
2.       Provide code example of an grid and server-side code example of how you return Query data. 
 
3.       Reproduce the issue in the attached sample. 
 
Regards, 
Prasanna Kumar N.S.V 
 



PK Prasanna Kumar Viswanathan Syncfusion Team May 30, 2016 03:55 PM UTC

Hi Grant,  
 
Please ignore the previous update. 
  
We created a sample and in this sample we used two buttons and a dropDownlist. One button is to store the state and another one is to retrieve the stored state.   
  
When we click the “Save State” button, using AJAX post will send the filterSettings and SortSettings property to server side and that will be stored into SQL data base.   
   
When we click on “Previous State” button, get the filterSettings and sortSettings Grid model from SQL data base and send it to client side using AJAX, then will update the Grid model using model values got from server-side.  
  
If the above sample does not meet your requirement or if you still want to restore Grid state using Grid Query property, then please provide us the following details.  
  
1.    In the actionBegin event you used getGridQuery method to rebind the query. So, we need the code example of an getGridQuery method.  
  
2.    Provide code example of an grid and server-side code example of how you return Query data.  
  
3.   Reproduce the issue in the attached sample.  
\ 
 
Regards,  
Prasanna Kumar N.S.V  


Loader.
Up arrow icon