Hybrid View
-
28 May 2012 8:16 PM #1
how to filter the data in NestedList using searchfield
how to filter the data in NestedList using searchfield
Can some one help me for the same ?
Thanks in advance !!!
-
29 May 2012 3:12 AM #2
Please find find below my code:
view/Main.js
view/listCollection.jsCode:config: { width: '40%', height: '100%', left :true, modal: true,l hideOnMaskTap: false, items: [ { xtype: 'listCollection', items:[ { xtype: 'toolbar', docked: 'top', maxHeight :'100%', items: [ { xtype: 'searchfield', width:'60%', height:'100%', }, { xtype: 'title', title : 'Select ', } ] }] } ] }
controller.jsCode:Ext.define('Test.view.ListCollection', { extend: 'Ext.NestedList', xtype: 'listCollection', requires: ['Test.store.DataStore_sub1'], config: { displayField: 'firstName', itemTpl: '{firstName}', store: 'DataStore_sub1', onItemDisclosure: true } });
please find below the image :-Code:config: { //stores: ['DataStore_sub1'], refs: { }, control: { 'searchfield': { placeHolder: 'search..', keyup: 'onSearchKeyUp' } } }, onSearchKeyUp:function(field) { //get the store and the value of the field var value = field.getValue(), store = Ext.getStore('DataStore_sub1'); ...... ..... ...}
sample.jpg
-
30 May 2012 8:51 AM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,128
- Vote Rating
- 453
You may want to filter the sub stores that each list gets.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
30 May 2012 8:56 AM #4
"You may want to filter the sub stores that each list gets."
yes, want to filter root data and as well sub store data as well through searchfield.
can you help for the same.
Thanks in Advance !!!
-
27 Sep 2012 12:21 AM #5
Hi,
Hahahaha…. I finally found it !! I created a workaround to filter the nested list
Ok lets assume the default documentation data :
Your model should have the following fields :Code:var data ={ name:'Don Griffin', title:'Senior Technomage', company:'Sencha Inc.', drinks:['Coffee','Water','More Coffee'], kids:[{ name:'Aubrey', age:17},{ name:'Joshua', age:13},{ name:'Cale', age:10},{ name:'Nikol', age:5},{ name:'Solomon', age:0}]};
Now, if you want to filter your nestedList and only show the parents who (say) have a kid named "Cale" you do the following :Code:fields : [
{name : 'name', type : 'string'}, {name : 'title', type : 'string'}, {name : 'company', type : 'string'}, {name : 'drinks', type : 'auto'}, {name : 'kids', type : 'auto'}, //This is the important one {name : 'age', type : 'integer'},]
1. Don't make a nested list component. Make only a list component and feed it the nested data above.
2. Use the filterBy function as below :
Now to the user it still looks like a nested list is being filteredCode:MyApp.stores.ListStore.filterBy(function(record,id){var theseKids = record.data.kids; //This takes the kids array using the "auto" type from the data and //feeds it into our variable. var flag = false; for(var i=0; i<theseKids.length; i++){if(theseKids[i].name.indexOf('Cade') != 0)flag = true;} return flag;});
If you need the data to look like a nested list all you need to do is use the NavigationView component to pull the data from the itemTap event and push a new view of a list with that array of data.
Cheers
Hope this helps somebody
Sasha


Reply With Quote