Clear grid store baseParams or reset them? - extjs

I have a grid list which I populate the baseParams using setBaseParam() method and then in a later event I clear the baseParams like so:
workorder_list_primary.store.baseParams = {};
workorder_list_primary.store.load();
console.log(workorder_list_primary.store);
But this isn't working? I need to reset the filter criteria completely. I have tried using load() and reload() -- any ideas?

Based on the use of setBaseParam() which is only available in ExtJS 3.4 I guees you are using version 3.x
Based on the source of store this makes no sense because baseParams = {} will definitely override the params. Other params will be pushed by paging, can be added to the load call or can be added within a 'beforeload' eventhandler. You may need to check all of them.

Related

ExtJs 6.2 ComboBox not send the remote filter

I'm working with extjs and strapi. so, I needed to some extra modification over proxy and store.
I tried to set remote filter combobox with paging according to docs but still can't pass queryParam into querystring!
my codes are in this fiddle:
https://fiddle.sencha.com/#view/editor&fiddle/3511
what is wrong with this code?
You remove your query parameter in basestore beforeload handler.
You must merge you new params with default store params. I'm fix it in my fiddle

Backbone PUT request explicitly with out using id

I'm trying to PUT the data and my model doesn't have an id.
Is it possible to explicitly tell the Save() method to PUT the data irrespective of ID.
The save method has an options parameter that can override anything on the XHR:
model.save(newVals, { type: 'PUT' })
You can also override the isNew method. PUT vs POST is determined by the result of that method. You'll also want to make sure the URL is being created correctly for new and non-new objects.
Also consider setting the idAttribute correctly so that your model does have an id field that can be used to generate a correct url. Using POST and PUT correctly (POST new items, PUT updates to items) makes your api more intuitive.

Show all rows in grid after clearing filters in ExtJS

I have a data store and a grid. I add filters in the store and they work properly as I see the results in my grid. But once I disable all my filters aka clear them from my store I want to view all my rows in the grid without reloading them from a web service which is a kind of heavy task. All data is already fetched from the service and there is no need to reaload it again.
How can I do this? Is there some function in the store?
There already was a similar question with correct answer. In short, you need to call filter method without params after setting remoteFilter to false:
store.remoteFilter = false;
store.clearFilter();
store.remoteFilter = true;
store.filter();
Here is a jsfiddle: http://jsfiddle.net/8Gmtd/
I suspect that your grid's view is not refreshed. Try this:
mygrid.getView().refresh()

How to find Table and append a new record to its Store?

I need to update a Store based on some information that I have.
I have a table in the document, that uses some Store to keep data,
and in separate part of page I have a button that needs to add some information to the Store (and table). I got a bit confused, so, I just ask here all I need to know:
Which property in table configuration needs to be specified to locate table later?
Which call I need to make to find the table and locate its store?
How I can generate and append data to the table's existing store?
The "table" you are referring to is Grid in ExtJS terminology.
1. To get the grid for later use, you need a reference to that object. There are many ways in ExtJS to get hold of this reference.
Using Javascript Variables: Most simple way is to have a javascript variable that will hold the reference. This is usually done when the grid is created. For example:
var myGrid = Ext.create('Ext.grid.Panel', {
// All the configs...
});
You can use the myGrid variable to get access to the grid.
Using ComponentManager: When an ExtJS component is created, it gets registered with the component manager. You can always get hold of an ExtJS component from this register. The manager tracks each component with a unique id. To use this method, you will have to define a unique id for your grid component and later use the famous Ext.getCmp() method. Here is an example:
var myGrid = Ext.create('Ext.grid.Panel', {
id: 'myGrid', // Unique id for the grid
// All other configs...
});
Using this method is NOT the best practice.
Using itemId and Component Query: A better method than the above two; you can use the itemId config and ComponentQuery. ComponentQuery class provides a selector-based searching for Sencha Components analogous to DOM querying. Example:
var myGrid = Ext.create('Ext.grid.Panel', {
itemId: 'myGrid',
// All other configs...
});
And to get a reference, you may call the query() method from a container or use Ext.ComponentManager (this is global).
Accessing in MVC controller: If you are developing your application using MVC, you can make use of this method. A controller have reference array namely: refs. (Internally, the method makes use of ComponentQuery and selectors to access the component). Refer MVC guides and examples to see how this works..
2. Once you obtain the grid with any the above techniques, you can get the store simply by calling the method: getStore(). This returns the store object (Ext.data.Store). Example:
myStore = myGrid.getStore();
3. Refer the Ext.data.Store documentation. you can manipulate your grid's store using methods like add(),load(),remove() etc...
FYI.
It is not
Ext.Cmp()
it is
Ext.getCmp('myGrid')

ExtJS: ajax based search form

I have an Ext.form.Panel that calls a PHP page by passing search parameters. The PHP page executes a query based on those params and returns a JSON structure. In the form-success handler I would like to get the JSON, build a store and fill a grid.
How can I do it using ajax? If I use Ext.form.panel submit() it always invoke onFailure because it does not find [{success:val,message:msg}]. Which is the correct way to build a form that gets back a JSON string?
Why don't you just have your search panel call a load() action on grid's JsonStore? A lot easier than manually flling the store from JSON string.

Resources