-
9 Jan 2012 6:40 AM #1
[ST2 PR3] Store filterBy error when the store has just one item.
[ST2 PR3] Store filterBy error when the store has just one item.
Thanks, Mitchellsimoens,
Actually the one I wrote down previously was happened in the middle of report THIS bug.
When I use a filterBy function, it keeps giving me the below message
Uncaught TypeError: Cannot call method 'addCls' of null
and I found out that when the list is filtered until the number of list item becomes just one,
the message show up.
I use the google Chrome 16, and here's the code I reorganized for you.
Code:Ext.application({ name: 'Joy', launch: function(){ var container = Ext.create('Ext.Container', { fullscreen: true, layout: 'fit', items:[ { xtype: 'toolbar', dock: 'top', title: 'JOY', items: [{ xtype: 'searchfield', id: 'searchTopicField', placeHolder : 'Topic', border: '1', width: '99%', margin: '5', listeners: { keyup : function( textField, event, options ){ var searchList = container.getComponent('searchTopicList'), textValue = textField.getValue(), searchListStore = searchList.getStore(); console.log(textValue); if(textValue.length > 0){ searchList.setHidden(false); var find = false, firstRecord; searchList.getStore().filterBy(function(record){ fieldData = record.data.topic.toLowerCase().indexOf(textValue); if(fieldData > -1){ return record; } }); }else{ if(searchListStore.isFiltered()){ searchListStore.clearFilter(); } searchList.setHidden(true); } } } }], }, { xtype: 'list', id: 'searchTopicList', flex : 1, scrollable : true, grouped: true, selectedCls: 'x-list-footer-item', store: { fields: ['id', 'bigtopic' ,'topic'] , sorters: 'bigtopic', getGroupString : function(record) { return record.get('bigtopic'); }, data: [ {bigtopic: 'Agriculture', topic: 'Agriculture' }, {bigtopic: 'Economics', topic: 'Economics'}, {bigtopic: 'Education', topic: 'Education economy and society'}, {bigtopic: 'Education', topic: 'Higher education and adult learning'}, {bigtopic: 'Education', topic: 'Preschool and school'}, {bigtopic: 'Education', topic: 'Research and knowledge management'}, {bigtopic: 'Employment', topic: 'Employment'}, {bigtopic: 'Science', topic: 'Science'} ], proxy: { type: 'localstorage', id: 'id' } }, itemTpl: "<div class='joy_list'>{topic}</div>" } ] }); } });
-
9 Jan 2012 7:01 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
I tried this and got not error:
Code:var list = container.down('list'), store = list.getStore(); store.filterBy(function(rec) { return /education/i.test(rec.get('bigtopic')); });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.
-
9 Jan 2012 7:10 AM #3
would you please READ my word?
would you please READ my word?
I tried this and got an error:
which has just one item when it was filtered.
Code:var list = container.down('list'), store = list.getStore();store.filterBy(function(rec) { return /economics/i.test(rec.get('bigtopic'));});
-
9 Jan 2012 7:19 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
And what was the error as I got no errors.
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.
-
9 Jan 2012 7:24 AM #5
are you sure you tried with economics? not education?
-
9 Jan 2012 7:30 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
Ok, that one is an open bug when there is only one item in the group.
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.
-
9 Jan 2012 7:34 AM #7
okay no problem.
okay no problem.
please make it [OPEN]
-
9 Jan 2012 7:52 AM #8Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
There is already a bug open. I'm not going to open two for the same thing.
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.
-
9 Jan 2012 8:14 AM #9
I'm sure you know what I mean :)
I'm sure you know what I mean :)
I said it because the title of this thread is still 'closed'.
Anyway, you said open so it is open
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote