Sencha touch 2 sencha touch 2中的过滤

Sencha touch 2 sencha touch 2中的过滤,sencha-touch-2,Sencha Touch 2,我用的是Sencha Touch 2。使用store.filter时,所有te记录都将被筛选 Ext.define("ForumApp.view.ForumList", { extend: "Ext.navigation.View", requires:["Ext.dataview.List", "Ext.Toolbar", "Ext.field.Text", "Ext.field.TextArea"], xtype: "forumlistview", config: { items:

我用的是Sencha Touch 2。使用store.filter时,所有te记录都将被筛选

Ext.define("ForumApp.view.ForumList", {
extend: "Ext.navigation.View",
requires:["Ext.dataview.List", "Ext.Toolbar", "Ext.field.Text", "Ext.field.TextArea"],
xtype: "forumlistview",

config: {
    items: [{
        xtype: "toolbar",
        title: "Forum",
        docked: "top",
        items: [
                {
                    xtype: "button",
                    ui: "back",
                    action:'backButton',
                    text: "Logout"
                },
            { xtype: 'spacer' },
            {
                xtype: "button",
                text: 'New',
                ui: 'action',
                itemId: "newButton"
            }
        ]
    }, {
        xtype: "list",
        title:"welcome",
        store: "ForumStore",
        itemId:"notesList",
        loadingText: "Loading Notes...",
        emptyText: "<div class=\"notes-list-empty-text\">No notes found.</div>",
        onItemDisclosure: true,
        grouped: true,
        itemTpl: "<div class=\"list-item-title\">{title}</div>"       
    }],
    listeners: [{
        delegate: "#newButton",
        event: "tap",
        fn: "onNewButtonTap"
    }, {
        delegate: "#notesList",
        event: "disclose",
        fn: "onNotesListDisclose"
    }]
},    
onNewButtonTap: function () {
    console.log("newTopicCommand");
    this.fireEvent("newTopicCommand", this);
},
onNotesListDisclose: function (list, record, target, index, evt, options) {
    console.log("topicViewCommand");
    this.fireEvent('topicViewCommand', this, record);
  }
});

基本上我有一个主题列表。单击特定主题时,我希望显示该特定主题的评论列表。我正在使用2家商店。存储主题和主题ID的文件。存储注释的其他工具-主题、注释、topicID和commentID。因此,当我披露某个特定主题时,我会使用它的topicID来过滤我的评论库

Ext.define("ForumApp.view.ForumList", {
extend: "Ext.navigation.View",
requires:["Ext.dataview.List", "Ext.Toolbar", "Ext.field.Text", "Ext.field.TextArea"],
xtype: "forumlistview",

config: {
    items: [{
        xtype: "toolbar",
        title: "Forum",
        docked: "top",
        items: [
                {
                    xtype: "button",
                    ui: "back",
                    action:'backButton',
                    text: "Logout"
                },
            { xtype: 'spacer' },
            {
                xtype: "button",
                text: 'New',
                ui: 'action',
                itemId: "newButton"
            }
        ]
    }, {
        xtype: "list",
        title:"welcome",
        store: "ForumStore",
        itemId:"notesList",
        loadingText: "Loading Notes...",
        emptyText: "<div class=\"notes-list-empty-text\">No notes found.</div>",
        onItemDisclosure: true,
        grouped: true,
        itemTpl: "<div class=\"list-item-title\">{title}</div>"       
    }],
    listeners: [{
        delegate: "#newButton",
        event: "tap",
        fn: "onNewButtonTap"
    }, {
        delegate: "#notesList",
        event: "disclose",
        fn: "onNotesListDisclose"
    }]
},    
onNewButtonTap: function () {
    console.log("newTopicCommand");
    this.fireEvent("newTopicCommand", this);
},
onNotesListDisclose: function (list, record, target, index, evt, options) {
    console.log("topicViewCommand");
    this.fireEvent('topicViewCommand', this, record);
  }
});
//这是我的主要主题列表视图

Ext.define("ForumApp.view.ForumList", {
extend: "Ext.navigation.View",
requires:["Ext.dataview.List", "Ext.Toolbar", "Ext.field.Text", "Ext.field.TextArea"],
xtype: "forumlistview",

config: {
    items: [{
        xtype: "toolbar",
        title: "Forum",
        docked: "top",
        items: [
                {
                    xtype: "button",
                    ui: "back",
                    action:'backButton',
                    text: "Logout"
                },
            { xtype: 'spacer' },
            {
                xtype: "button",
                text: 'New',
                ui: 'action',
                itemId: "newButton"
            }
        ]
    }, {
        xtype: "list",
        title:"welcome",
        store: "ForumStore",
        itemId:"notesList",
        loadingText: "Loading Notes...",
        emptyText: "<div class=\"notes-list-empty-text\">No notes found.</div>",
        onItemDisclosure: true,
        grouped: true,
        itemTpl: "<div class=\"list-item-title\">{title}</div>"       
    }],
    listeners: [{
        delegate: "#newButton",
        event: "tap",
        fn: "onNewButtonTap"
    }, {
        delegate: "#notesList",
        event: "disclose",
        fn: "onNotesListDisclose"
    }]
},    
onNewButtonTap: function () {
    console.log("newTopicCommand");
    this.fireEvent("newTopicCommand", this);
},
onNotesListDisclose: function (list, record, target, index, evt, options) {
    console.log("topicViewCommand");
    this.fireEvent('topicViewCommand', this, record);
  }
});
//这是我的控制器

Ext.define("ForumApp.view.ForumList", {
extend: "Ext.navigation.View",
requires:["Ext.dataview.List", "Ext.Toolbar", "Ext.field.Text", "Ext.field.TextArea"],
xtype: "forumlistview",

config: {
    items: [{
        xtype: "toolbar",
        title: "Forum",
        docked: "top",
        items: [
                {
                    xtype: "button",
                    ui: "back",
                    action:'backButton',
                    text: "Logout"
                },
            { xtype: 'spacer' },
            {
                xtype: "button",
                text: 'New',
                ui: 'action',
                itemId: "newButton"
            }
        ]
    }, {
        xtype: "list",
        title:"welcome",
        store: "ForumStore",
        itemId:"notesList",
        loadingText: "Loading Notes...",
        emptyText: "<div class=\"notes-list-empty-text\">No notes found.</div>",
        onItemDisclosure: true,
        grouped: true,
        itemTpl: "<div class=\"list-item-title\">{title}</div>"       
    }],
    listeners: [{
        delegate: "#newButton",
        event: "tap",
        fn: "onNewButtonTap"
    }, {
        delegate: "#notesList",
        event: "disclose",
        fn: "onNotesListDisclose"
    }]
},    
onNewButtonTap: function () {
    console.log("newTopicCommand");
    this.fireEvent("newTopicCommand", this);
},
onNotesListDisclose: function (list, record, target, index, evt, options) {
    console.log("topicViewCommand");
    this.fireEvent('topicViewCommand', this, record);
  }
});
 Ext.define("ForumApp.controller.ForumController", {

extend: "Ext.app.Controller",
config: {
    refs: {
        forumListView: "forumlistview",
        commentList: "#commentlist"
    },
    control: {
        forumListView: {
            topicViewCommand: "onTopicViewCommand"
        }
        }
},

onTopicViewCommand: function (list, record) {

    this.getCommentList().getStore().clearFilter();
    this.getCommentList().getStore().filter([{property:'id',value: record.data.id}]);

    this.getForumListView().push({
    xtype: 'topiccommentview',
    title: record.titleName(),
    data: record.data
    });
},

// Base Class functions.
launch: function () {
    this.callParent(arguments);
    var forumStore = Ext.getStore("ForumStore");
    forumStore.load();
    var commentStore = Ext.getStore("CommentStore");
    commentStore.load();
    var userStore = Ext.getStore("UserStore");
    userStore.load();
},
init: function () {
    this.callParent(arguments);
}
 });
//这是我的评论模型

Ext.define("ForumApp.view.ForumList", {
extend: "Ext.navigation.View",
requires:["Ext.dataview.List", "Ext.Toolbar", "Ext.field.Text", "Ext.field.TextArea"],
xtype: "forumlistview",

config: {
    items: [{
        xtype: "toolbar",
        title: "Forum",
        docked: "top",
        items: [
                {
                    xtype: "button",
                    ui: "back",
                    action:'backButton',
                    text: "Logout"
                },
            { xtype: 'spacer' },
            {
                xtype: "button",
                text: 'New',
                ui: 'action',
                itemId: "newButton"
            }
        ]
    }, {
        xtype: "list",
        title:"welcome",
        store: "ForumStore",
        itemId:"notesList",
        loadingText: "Loading Notes...",
        emptyText: "<div class=\"notes-list-empty-text\">No notes found.</div>",
        onItemDisclosure: true,
        grouped: true,
        itemTpl: "<div class=\"list-item-title\">{title}</div>"       
    }],
    listeners: [{
        delegate: "#newButton",
        event: "tap",
        fn: "onNewButtonTap"
    }, {
        delegate: "#notesList",
        event: "disclose",
        fn: "onNotesListDisclose"
    }]
},    
onNewButtonTap: function () {
    console.log("newTopicCommand");
    this.fireEvent("newTopicCommand", this);
},
onNotesListDisclose: function (list, record, target, index, evt, options) {
    console.log("topicViewCommand");
    this.fireEvent('topicViewCommand', this, record);
  }
});
  Ext.define("ForumApp.model.CommentModel", {
extend: "Ext.data.Model",
config: {
    idProperty: 'commentId',
    fields: [
        { name: 'commentId', type: 'int' },
        { name: 'id', type: 'int' },
        { name: 'dateCreated', type: 'date', dateFormat: 'c' },
        { name: 'title', type: 'string' },
        { name: 'username', type: 'string' },
        { name: 'narrative', type: 'string' }
    ],
    validations: [
        { type: 'presence', field: 'id' },
        { type: 'presence', field: 'commentId' },
        { type: 'presence', field: 'dateCreated' },
        { type: 'presence', field: 'title', message: 'Please enter a title for this note.' }
    ]
},
titleName: function(){
    var d=this.data,
    names=[
        d.title
        ];
        return names;
}
  });
//这是我的评论商店

Ext.define("ForumApp.view.ForumList", {
extend: "Ext.navigation.View",
requires:["Ext.dataview.List", "Ext.Toolbar", "Ext.field.Text", "Ext.field.TextArea"],
xtype: "forumlistview",

config: {
    items: [{
        xtype: "toolbar",
        title: "Forum",
        docked: "top",
        items: [
                {
                    xtype: "button",
                    ui: "back",
                    action:'backButton',
                    text: "Logout"
                },
            { xtype: 'spacer' },
            {
                xtype: "button",
                text: 'New',
                ui: 'action',
                itemId: "newButton"
            }
        ]
    }, {
        xtype: "list",
        title:"welcome",
        store: "ForumStore",
        itemId:"notesList",
        loadingText: "Loading Notes...",
        emptyText: "<div class=\"notes-list-empty-text\">No notes found.</div>",
        onItemDisclosure: true,
        grouped: true,
        itemTpl: "<div class=\"list-item-title\">{title}</div>"       
    }],
    listeners: [{
        delegate: "#newButton",
        event: "tap",
        fn: "onNewButtonTap"
    }, {
        delegate: "#notesList",
        event: "disclose",
        fn: "onNotesListDisclose"
    }]
},    
onNewButtonTap: function () {
    console.log("newTopicCommand");
    this.fireEvent("newTopicCommand", this);
},
onNotesListDisclose: function (list, record, target, index, evt, options) {
    console.log("topicViewCommand");
    this.fireEvent('topicViewCommand', this, record);
  }
});
  Ext.define("ForumApp.store.CommentStore", {
extend: "Ext.data.Store",
requires: "Ext.data.proxy.LocalStorage",
config: {
    model: "ForumApp.model.CommentModel",
    proxy: {
        type: 'localstorage',
        id: 'comment-store-2'
    },
    sorters: [{ property: 'dateCreated', direction: 'DESC'}],
    grouper: {
        sortProperty: "dateCreated",
        direction: "DESC",
        groupFn: function (record) {

            if (record && record.data.dateCreated) {
                return record.data.dateCreated.toDateString();
            } else {
                return '';
            }
        }
    }
   }
 });

另外,当我在商店中使用过滤器时,它不会过滤商店。你的问题不清楚,解释一下你想实现什么,你做了什么来实现它(通常是你的代码),最后是什么不起作用。基本上我有一个主题列表。单击特定主题时,我希望显示该特定主题的评论列表。我正在使用2家商店。存储主题和主题ID的文件。存储注释的其他工具-主题、注释、topicID和commentID。因此,当我披露一个特定的主题时,我会使用它的topicID来过滤我的评论库。显示您的代码以获得帮助,并更多地描述您的提问;this.getCommentList().getStore().filter([{property:'id',value:record.data.id}]);我无法过滤商店。该命令正在过滤整个存储,因此我总是得到一个空列表