PDA

View Full Version : Form + Grid issue



zero_sencha
10 May 2012, 12:51 AM
I'm using GridPanel in my app, and I create js by Architect2. I want to load grid after submitted the form(not ext form panel), i.e. the form as a search bar. My code like:


app.js:
Ext.Loader.setConfig({
enabled: true
});

Ext.application({
models: [
'myModel'
],
stores: [
'myDataStore'
],
views: [
'myGrid'
],
autoCreateViewport: true,
appFolder: 'extjs/app',
name: 'myApp'
});



myDataStore.js:
Ext.define('myApp.store.myDataStore', {
extend: 'Ext.data.Store',
requires: [
'NtrApp.model.myModel'
],

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
storeId: 'MyJsonStore',
model: 'myApp.model.myModel',
pageSize: 20,
proxy: {
type: 'ajax',
url: 'test.do?' + params, ////###params is the form's values
reader: {
type: 'json',
root: 'root'
}
}
}, cfg)]);
}
});



app.html:
...
<form id="myform">
Name: <input id="name" name="name"/>
Age: <input id="age" name="age"/>
<input type="submit" name="submit" value="Search"/>
</form>
<div id="gridUsers"></div>
...


My question is how to re-load the grid(or data store)? Note the url of datastore is dynamic. Thanks.

vietits
10 May 2012, 1:03 AM
Try:


<grid>.getStore().load({
params: {
filters: filters
}
});

zero_sencha
10 May 2012, 1:28 AM
Try:


<grid>.getStore().load({
params: {
filters: filters
}
});
Thank you.
But I want to search the data from server, not filter data from store.

vietits
10 May 2012, 1:59 AM
In my example, 'filters' is just a name of a parameter that will be sent to server side script. It is not store filters. You can use any name instead.