sencha touch - 手风琴布局

发布于 2024-12-06 21:40:24 字数 711 浏览 0 评论 0原文

在这段代码中......

    var panel = new Ext.Panel({
        fullscreen : true,
        scroll     : "vertical",
        layout     : {
            type :  "accordion"
        },
        items: [
            { xtype : "panel", title : "One Title",   html : "One"   },
            list,
            { xtype : "panel", title : "Three Title", html : "Three" },
            { xtype : "panel", title : "Four Title",  html : "Four"  },
            { xtype : "panel", title : "Five Title",  html : "Five"  },
            { xtype : "panel", title : "Six Title",   html : "Six"   }
        ]
    });

在此,面板标题被硬编码为一个标题,三个标题等。但我想显示我从数据库中获得的结果(我已经创建了模型,并且我得到了结果显示)作为每个面板的标题...如何迭代和显示..请帮助我..

In this code ...

    var panel = new Ext.Panel({
        fullscreen : true,
        scroll     : "vertical",
        layout     : {
            type :  "accordion"
        },
        items: [
            { xtype : "panel", title : "One Title",   html : "One"   },
            list,
            { xtype : "panel", title : "Three Title", html : "Three" },
            { xtype : "panel", title : "Four Title",  html : "Four"  },
            { xtype : "panel", title : "Five Title",  html : "Five"  },
            { xtype : "panel", title : "Six Title",   html : "Six"   }
        ]
    });

In this, the panel title were hard coded as One title, Three title, etc.. but i want to display the result what i am getting from database (i have created the model and i got the result to display) as title of each panel ... how to iterate and show .. pls help me..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

在梵高的星空下 2024-12-13 21:40:24

您可以将结果收集到一个数组中,然后将该数组添加到面板的项目中。可能是这样的:

var panels = [];
for ( var i=0; i<results.length; i++ ) { 
var p= '{ xtype : "panel", title : ' + results[i].title + ',   html : "' + results[i].html  + '"   },';
panels.push(p);
}

var panel = new Ext.Panel({
    fullscreen : true,
    scroll     : "vertical",
    layout     : {
        type :  "accordion"
    },
    items: panels
});

You could collect the results in an array then add this array to panel's items. Could be something like this:

var panels = [];
for ( var i=0; i<results.length; i++ ) { 
var p= '{ xtype : "panel", title : ' + results[i].title + ',   html : "' + results[i].html  + '"   },';
panels.push(p);
}

var panel = new Ext.Panel({
    fullscreen : true,
    scroll     : "vertical",
    layout     : {
        type :  "accordion"
    },
    items: panels
});
小姐丶请自重 2024-12-13 21:40:24

我通过使用以下内容获得了手风琴面板中的动态值

 var panel = new Ext.Panel({

layout: {
        type: "accordion"
    },

    initComponent : function() {

allVisitStore.data.each(function() {
                alert('inside teration');
                jsonObj.push({xtype:"panel", title: this.data['title'], html : this.data['patientId'], style : 'padding-bottom:10px;'});
            });

}
});

I got the dynamic value in accordion panel by using the following

 var panel = new Ext.Panel({

layout: {
        type: "accordion"
    },

    initComponent : function() {

allVisitStore.data.each(function() {
                alert('inside teration');
                jsonObj.push({xtype:"panel", title: this.data['title'], html : this.data['patientId'], style : 'padding-bottom:10px;'});
            });

}
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文