PDA

View Full Version : Search in the JSON Store Grid



sthanar
7 Aug 2013, 3:55 AM
Hi,

I have grid loading data using JSON store.

var store = new Ext.data.JsonStore({
root: 'topics',
totalProperty: 'totalCount',
idProperty: 'threadid',
remoteSort: true,
//url: 'http://extjs.com/forum/topics-browse-remote.php',
fields: [
'title', 'forumtitle', 'forumid', 'username',
{name: 'replycount', type: 'int'},
{name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
'lastposter', 'excerpt'
],
proxy: new Ext.data.HttpProxy({
url: '/apps/FusionChartConsole'
})
});
store.setDefaultSort('lastpost', 'desc');

now the store has 25 records as i implemented paging grid. I want to search these 25 records using the fieldname and reload the store only the matching records among 25.

i just put the below line in search button click event. But it is not working.
store.reload({params:{username:'testuser'}});

i stuck in these whole day. Help me out of this..

willigogs
7 Aug 2013, 4:48 AM
If you're only wanting to search amongst the currently loaded records, then surely you could just filter the store, rather than reloading it?

This way you don't need an additional call to the DB.

http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.Store-method-filter

sthanar
12 Aug 2013, 4:30 AM
This is worked for me.
grid.getStore().filter('employee', new RegExp("^"+schFiled.getValue()+"$"));