简体   繁体   中英

Sencha Touch filter dataview store and refresh list

Seems easy enough but after hours and hours of wasted time I must ask.

I have a nested dataview list with a store that gets populated from an api. Each record is neat and and easy to parse. Like this:

 title: 'some title'
 starred: false       // some are "starred: true" and thats what I want
 state: 1
 statetyped: 1

I simply need to tap a button that says "starred" and filter the list to show just the starred items.

I have tried everything under the sun, including:

    sto.filterBy(function(record){
        var title = record.get('starred');
        if(title == "true" || title == true)
            return record;
    });

    //doesnt work 

    sto.filter(function (record) {
        if (record.data.starred == true) {
            return record;
        }
    });

    //same, doesn't work

I even got desperate and filtered the list with underscore.js, created a new store and tried to load the new store, but to no avail.


The console error is: Uncaught TypeError: Cannot call method 'detach' of null (Default.js?_dc=1392147674804:140)

If it helps:

my dataview view: http://jsfiddle.net/8ycnR/
list controller: http://jsfiddle.net/a7ZaX/

If you have in your model starred field type configured as bool you can simply use Ext.data.Store filter() method.

As first parameter you should pass property name and as second parameter value to filter by:

sto.filter('starred', true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM