How to change extraParams proxy configuration at runtime in extjs?

I have the following repository:

var store = new Ext.data.Store({ model: 'Result', proxy: { type: 'ajax', extraParams: {search_term : term}, url : 'find.pl' }, }); 

How to change the parameters with which the url is called (e.g. search_term) at runtime?

+6
source share
4 answers

Think of it like -
You are not calling the url. You are loading the repository.

Now you can specify the value of search_term whenever you try to load the repository using something like

 store.load({ params:{ search_term:'my runtime search term' } //other options like a callback function, append/add flag, etc. }); 
+7
source

Assuming you want to change the parameters after defining the store variable. Obviously, this will depend on whether Ext.data.Store allows parameter changes. If it allows, then it's that simple: store.proxy.extraParams.search_term = //something

+1
source
 var form = this.up('form').getForm(); var searchText = form.getValues('search_term').split("=")[1]; var resultGrid = Ext.widget('ResultGrid'); var store = resultGrid.getStore(); if (searchText != undefined && searchText != '') { store.proxy.extraParams.bomId = searchText; } resultGrid.store.load(); } 
0
source
 store.proxy.extraParams.search_term = 'any value'; //set extraparams field store.load() //load the store 

But you need to take care of IE8 .. check it out

0
source

Source: https://habr.com/ru/post/892580/


All Articles