extjs - 带有子面板和圆环图的 ExtJS 面板布局
问题描述
我正在尝试实现类似于下面的布局,其中一个面板左侧包含 2 个框,右侧包含一个圆环图(包含在它自己的面板中)。
单击左侧的任一框将触发图表的重新加载。
我不清楚哪些元素最适合左侧的可点击框,以及如何将它们与图表对齐。容器会更容易根据需要定位元素吗?
感谢您的任何帮助。
解决方案
要实现你想要的布局,有几种方法。最流行的是边框布局和组合 v hbox 和 vbox 布局。我会展示两者。
对于单击侦听器,如果按钮不是选项,您也可以使用容器,侦听器实现也在示例中。
边框布局主要用于主面板。
这是边框布局示例,这里是小提琴
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
title: "Main Panel",
width: "100%",
bodyPadding: 5,
height: Ext.getBody().getHeight(),
layout: "border",
items: [{
xtype: "panel",
title: "leftContainer",
region: "west",
width: 300,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [{
type: "conatiner",
style: "border:1px solid red",
html: "first container",
flex: 1,
listeners: {
el: {
click: function () {
alert("first Container")
}
}
}
}, {
type: "conatiner",
style: "border:1px solid red",
html: "secon container",
flex: 1,
listeners: {
el: {
click: function () {
alert("second Container")
}
}
}
}]
}, {
xtype: "panel",
margin: "0 0 0 5",
title: "center Container",
region: "center"
}]
})
第二个例子是通过布局 hbox 实现的,这里是小提琴
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
title: "Main Panel",
width: "100%",
bodyPadding: 5,
height: Ext.getBody().getHeight(),
layout: {
type: 'hbox',
align: 'stretch'
},
items: [{
xtype: "panel",
title: "leftContainer",
width: 300,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [{
type: "conatiner",
style: "border:1px solid red",
html: "first container",
flex: 1,
listeners: {
el: {
click: function () {
alert("first Container")
}
}
}
}, {
type: "conatiner",
style: "border:1px solid red",
html: "secon container",
flex: 1,
listeners: {
el: {
click: function () {
alert("second Container")
}
}
}
}]
}, {
xtype: "panel",
margin: "0 0 0 5",
title: "center Container",
flex: 1
}]
})
推荐阅读
- loops - 在 for 循环的输出中,它显示为零并且不接受输入我无法弄清楚我在这里做错了什么
- javascript - 无法读取未定义的 javaScript 的属性“长度”
- automated-tests - 当 selenium 服务器处于并行模式时,是否可以将所有测试套件合并到一个 html 文件中?
- typescript - 动态渲染功能子组件
- ios - 控制台中打印出意外的变量结果
- javascript - 按提供的输入过滤值
- c# - 'INSERT 语句中的列多于 VALUES 子句中指定的值' C# 到 SQL
- python - 使用 Scrapy 管道而不使用 settings.py 配置
- c++ - 只在函数中设置静态变量一次
- json - 在 Angular 中使用 JSON 数据填充模型