更新Sencha Touch 2中的嵌套列表 [英] update a nested list in sencha touch 2

查看:15
本文介绍了更新Sencha Touch 2中的嵌套列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用sencha Touch 2重新绘制嵌套列表时遇到问题。我的代码如下所示;

  var data = {items:[{text:'hello', leaf:true}]};
    Ext.application({
       name:'main',
       launch:function(){

            Ext.define('ListItem', {
                extend: 'Ext.data.Model',
                config: {
                    fields: ['text']
                }
            });

            var treeStore = Ext.create('Ext.data.TreeStore', {
                id: 'mystore',
                model: 'ListItem',
                defaultRootProperty: 'items',
                root: data});

            Ext.create('Ext.NestedList', {
                id:'mylist',
                fullscreen: true,
                store: treeStore
            });

        } // end launch:function()
     }); // end Ext.application

在运行时,我这样修改数据变量data.items[0].text = 'bye'。如何刷新并显示bye嵌套列表?我尝试了以下方法,但都不起作用:

var mystore = Ext.data.StoreManager.lookup('mystore');
mystore.setRoot(data);
Ext.getCmp('mylist').refresh(); // refresh, update, dolayout, repaint etc... does not exist.
Ext.getCmp('mylist').bindstore(mystore); // bindstore is deprecated

推荐答案

您只需通过记录/存储实例更改数据,Ext.NestedList就会自动更新

var record = treeStore.getAt(0);
record.set('text', 'bye');

这篇关于更新Sencha Touch 2中的嵌套列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆