首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ExtJS6:将存储绑定到面板项

ExtJS6:将存储绑定到面板项
EN

Stack Overflow用户
提问于 2017-01-06 00:13:10
回答 2查看 1.3K关注 0票数 1

ExtJS6是否允许存储绑定到简单面板项,以便提取指定列并将它们显示为项{ xtype:' panel ',id:'master_list',title:'MasterList',defaultType:'button',绑定:{ store:'{zones}‘}}

EN

回答 2

Stack Overflow用户

发布于 2017-01-06 01:59:16

在extJS 6中,面板上的项配置不是可绑定项,这主要是因为在面板上找不到getItem()和setItems()方法。您可以随时重写面板并添加该功能,它将如下所示:

代码语言:javascript
复制
Ext.define("Ext.panel.StoreButtonPanel", {
    /* extend a panel so you get same base functionality of a panel */
    extend: 'Ext.panel.Panel',
    /* other configs and overrides you might want */


    setStore:function(){
        // function to bind the store to panel
    },

    getStore:function(){
        // function to get store from panel
    }


    setItems: fuunction(){
        var me = this, 
            myStore = me.getStore();

        // loop through store and add items. 
        myStore.each(function(storeItem){
            // create the items that you want from teh store via loop and using 
            // storeItem
            Ext.create('Ext.button.Button', { 
                text: storeItem.get('text'),
                /* other things here if needed */
            })
        });

    },


    init: function(){
        var me = this;

        // call method to create items if a store is found. 
        if(me.getStore()){
            me.setItems();
        }
        me.callParent();
    }
});
票数 1
EN

Stack Overflow用户

发布于 2017-03-16 21:32:23

您可以将store参数添加到您的面板。Extjs将直接加载存储。

代码语言:javascript
复制
store: Ext.Create('Yourapp.store.storename'),

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41489659

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档