0
votes

On my UI, I've a grid where I'm applying filters on columns and getting filtered data. In my REST request, my UI is sending filter as a key:value like this:

filter:[{"operator":"gt","value":222,"property":"qty_raw"}]

and, I want to extract the same filter data from the same grid (using ComponentQuery) so that I can send the same filter/filters(more than one column) in another request on a button click handler, I am writing code in EXTJS like this,

var gridObj = Ext.ComponentQuery.query('myGridId')[0];
var filters = gridObj.store.getFilters();
console.log("print filters.....",filters);

filters in Chrome tool looks like the following snapshot, where the data which I need is in items and map, but I can't reach to the data. I don't know if there is any better way to do this? any suggestions?

filters collection as shown on chrome developer tool

Update: I tried doing it using store lastOptions property, it still not working (Error: Uncaught TypeError: Cannot read property 'params' of undefined)

     var gridObj = Ext.ComponentQuery.query('Grid_xx')[0];
     var lastOptions = gridObj.store.lastOptions,
     lastParams = Ext.clone(lastOptions.params);
     lastParams.limit = limit; //;var limit = gridObj.store.getTotalCount();
     lastParams.page = page; // var page = 1
     lastParams.start = start; // var start= 1
     lastParams.columnsNameArray = JSON.stringify(columnsNameArray);
     console.log("columnArray............ =",lastParams.columnsNameArray);
     var encodedFilename = Ext.urlEncode(lastParams);
     Ext.create('Ext.Component', {
         renderTo: Ext.getBody(),
         //url: EfwSlamUI.Config.restUrl.GridExport,
         cls: 'x-hidden',
         params: lastParams,
         autoEl: {
             tag: 'iframe',
             src: Abc.Config.restUrl.GridExport + '?' + encodedFilename}
 });
1

1 Answers

0
votes

One suggestion:

I think a better approach would be to use the store.reload() function because it will automatically use the last params used by the last stores request.

https://docs.sencha.com/extjs/6.0/6.0.0-classic/#!/api/Ext.data.BufferedStore-method-reload

You can change the filters / sorters on the grid or store.

https://docs.sencha.com/extjs/6.0/6.0.0-classic/#!/api/Ext.data.BufferedStore-property-lastOptions

If you wanna prevent auto-reload of the grid, if a filter is changed, disable autoLoad of the store.