繁体   English   中英

如何在sencha touch中获取嵌套列表?

[英]How can i get Nested List in sencha touch?

我有以下主要文件:

app.js:

Ext.Loader.setConfig({
});
Ext.application({
    views: [
        'Login',
        'Inner',
        'Group',
        'Innerdata',
        'Grptoolbar'
    ],
    stores:[
        'MyStore'
    ],
    models:[
        'MyModel'
    ],
    name: 'chat',

    launch: function() {
        Ext.create('chat.view.Login', {fullscreen: true});
    }
});

Group.js:是列表的查看文件。

Ext.define('chat.view.Group', {
    extend: 'Ext.Group',
    alias: "widget.Group",
    xtype:'Group',
    requires:['Ext.dataview.List','Ext.data.Store'],

    config:{
    title:'My List',
    layout:'fit',
     items: [
        {
            xtype:'list',
            store:'MyStore',
            itemTpl:'<b>{name}<b>'
        },
     ]
  },
});

MyModel.js:

Ext.define('chat.model.MyModel',{
    extend:'Ext.data.Model',
    config:{
        fields: [
        {name: 'text', type: 'string'},
        {name: 'card'}
    ]
    }
});

MyStore.js

Ext.define('chat.store.MyStore',{
    extend:'Ext.data.TreeStore',
    config:{
        model:'chat.model.MyModel',
        root: {
       items: [{
            text: 'About',
            card: {xtype: 'Grptoolbar'},
            leaf: true
        }
        ],
        },
        autoLoad:true,
        proxy: {
        type: 'ajax',
        reader: {
            type: 'tree',
            root: 'items'
        }
    }
    }
});

我试图创建嵌套List.so,我创建了存储,模型和查看文件。
目前,我遇到此错误:

错误:[Ext.createByAlias]无法创建无法识别的别名的实例:reader.tree

如果我从MyStore.js删除以下行,则错误消失并且应用程序正在运行,但我还没有列表。

proxy: {
        type: 'ajax',
        reader: {
            type: 'tree',
            root: 'items'
        }
    }   

那么我该如何解决呢? 所以我得到了我的嵌套列表。

没有“树阅读器”,因此您不能使用配置type: 'tree' ,允许的选项为:json,xml,data,array。

同样,当您使用嵌套列表时,也无需为代理定义“树阅读器”。 我认为仅此而已:

Ext.define('chat.store.MyStore',{
    extend:'Ext.data.TreeStore',
    config:{
        model:'chat.model.MyModel',
        root: {
          items: [{
            text: 'About',
            card: {xtype: 'Grptoolbar'},
            leaf: true
          }],
        },
        autoLoad:true,
        defaultRootProperty: 'items'
    }
    }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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