简体   繁体   English

如何在面板EXTJS内的列表/表中加载动态数据

[英]How to load dynamic data in a list/table inside a panel-EXTJS

I'm trying to create a panel like: 我正在尝试创建一个面板,如:

在此处输入图片说明

with the below code as a beginning, however I'm not sure how can I create a list/table inside a panel in a way like it looks below in the image. 以下面的代码作为开始,但是我不确定如何在面板内创建列表/表,其方式类似于图像下面的样子。 I also have to load the data dynamically inside the panel. 我还必须在面板内部动态加载数据。 also I'm using panel since I want it to be a collapsible one 我也正在使用面板,因为我希望它可以折叠

$cls.superclass.constructor.call(this, Ext.apply({
  items: [
    this.section({
      items: [
        this.panel = new Ext.Panel({
          items: [
            this.section({
              items: []
            })
          ],

          collapsible: true,
        })
      ]
    })
  ]
}, cfg));

Ext.extend($cls, Panel, {

  getData: function(data) {
    //here I have the entire data I want to show in the list. just not sure how?
  }

});

any ideas? 有任何想法吗?

You can create custom rows with Ext.Panel. 您可以使用Ext.Panel创建自定义行。 The example shows only show creating list. 该示例仅显示节目创建列表。 To add part where AND, OR you can change structure of data and create row with nested panel row. 要在AND,OR之间添加零件,您可以更改数据结构并使用嵌套面板行创建行。

Here is example of creating custom list with panel: 这是使用面板创建自定义列表的示例:

Ext.onReady(function () {
    Ext.create({
        xtype: 'panel',
        renderTo: Ext.getBody(),
        title: 'ExtJS Master Panel',
        items: [
            collapsibleList = new Ext.Panel({
                title: 'Collapsible List',
                collapsible: true,
                hideBorders: true,
                padding: '10px',
                height: 400
            })
        ],
        getData: function () {
            return new Promise(function (resolve) {
                setTimeout(function () {
                    resolve([{
                        name: 'Last VM Scan',
                        decider: 'LESS THAN',
                        period: '30 days'
                    }, {
                        name: 'Last CERTVIEW Scan',
                        decider: 'LESS THAN',
                        period: '14 day'
                    }, {
                        name: 'Last checked In',
                        decider: 'LESS THAN',
                        period: '10 days'
                    }]);
                }, 1000);
            });
        },
        listeners: {
            afterrender: function () {
                console.log(collapsibleList);
                Promise.resolve(this.getData()).then(function (data) {
                    for (var i = 0; i < data.length; i++) {
                        var pan = new Ext.Panel({
                            xtype: 'panel',
                            layout: 'hbox',
                            hideBorders: true,
                            items: [{
                                xtype: 'panel',
                                padding: '10px',
                                width: 200,
                                items: [{
                                    xtype: 'label',
                                    text: data[i].name
                                }]
                            }, {
                                xtype: 'panel',
                                padding: '10px',
                                width: 300,
                                items: [{
                                    xtype: 'label',
                                    text: data[i].decider
                                }]
                            }, {
                                xtype: 'panel',
                                padding: '10px',
                                items: [{
                                    xtype: 'label',
                                    text: data[i].period
                                }]
                            }]
                        });

                        collapsibleList.add(pan);
                    }

                    collapsibleList.doLayout();
                });
            }
        }
    });
});

Working Fiddle Link: https://fiddle.sencha.com/#view/editor&fiddle/2l14 工作小提琴链接: https : //fiddle.sencha.com/#view/editor&fiddle/2l14

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

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