【发布时间】:2023-03-20 00:51:01
【问题描述】:
在我的 extjs6 版本 6.0.0.640 项目中,当我填充我的网格和图表时,布局运行失败。 我的面板布局设置为边框。在中心区域,我有一个合适的布局。然后尝试有 3 行,但在其中我想放入 hbox 的行中。到目前为止,我的布局是这样的。如果我删除 hbox 它可以工作,但我想将多个项目放在我的一行中。
Ext.define('ExtApplication4.view.historical.Historical', {
extend: 'Ext.panel.Panel',
xtype: 'app-historical',
controller: 'historical',
itemId: 'historicalItemId',
requires: [
'ExtApplication4.view.historical.HistoricalController',
'ExtApplication4.util.GlobalVar',
'Ext.chart.*'
],
title: 'Historical',
layout: {
type: 'border'
},
defaults: {
split: true,
bodyPadding: 15
},
items: [
{
title: 'Accounts',
region: 'west',
margin: '5 0 0 0',
width: 100,
//html: 'this is the menu account area',
dockedItems: [
{
xtype: 'toolbar',
dock: 'left',
//cls: 'myBgCls',
style: 'padding: 0; margin: 0;'
//items: [
// {
// xtype: 'combobox',
// itemId: 'comboboxClientItemID',
// emptyText: 'Select Client...',
// editable: false,
// displayField: 'clientName',
// valueField: 'clientName',
// bind: {
// store: '{myClientListStore}',
// selection: '{selectedClientListModel}'
// },
// listeners: {
// select: 'onComboboxSelect'
// },
// queryMode: "local"
// }
//]
}
]
},
{
title: 'Main Content',
region: 'center',
layout: {
type: 'fit'
},
items: [
{
layout: {
type: 'vbox',
align: 'stretch'
},
items: [
{
xtype: 'button'
},
{
flex: 1,
title: 'Sector',
xtype: 'grid',
ui: 'featuredpanel-framed',
itemId: 'attributionSectorGridID',
cls: 'custom-grid',
margin: '0px 0px 0px 0px',
bind: {
store: '{myAttributionGroupedStore}'
},
columns: [
{
header: 'Sector',
dataIndex: 'Sector',
flex: 1
},
{
header: 'P&L',
dataIndex: 'DailyPL',
renderer: function (value) {
var newVal;
var calc = value.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
if (value > 0) {
newVal = '<span style="color:green">' + "$" + calc + '</span>';
} else if (value < 0) {
newVal = '<span style="color:red">' + "$" + calc + '</span>';
} else {
newVal = "$" + calc;
}
return newVal;
},
align: 'right',
flex: 1
}
]
},
{
xtype: 'panel',
flex: 3,
layout: {
type: 'hbox',
align: 'stretch'
},
items: [
{
title: 'Winners',
xtype: 'grid',
ui: 'featuredpanel-framed',
itemId: 'attributionWinnersGridID',
cls: 'custom-grid',
margin: '5px 0px 0px 0px',
bind: {
store: '{myAttributionWinnersStore}'
},
columns: [
{
header: 'Sector',
dataIndex: 'Sector',
flex: 1
},
{
header: 'Market',
dataIndex: 'ShortDesc',
flex: 1
},
{
header: 'P&L',
dataIndex: 'DailyPl',
renderer: function (value) {
var newVal;
var calc = value.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
if (value > 0) {
newVal = '<span style="color:green">' + "$" + calc + '</span>';
} else if (value < 0) {
newVal = '<span style="color:red">' + "$" + calc + '</span>';
} else {
newVal = "$" + calc;
}
return newVal;
},
align: 'right',
flex: 1
}
]
}
]
}
]
}
]
}
]
});
【问题讨论】:
-
尝试删除项目直到它起作用,然后将它们添加回来,您会找到导致此问题的项目。
-
我做到了...导致它中断的部分是我在代码底部添加 hbox 时。如果我删除它,它会起作用。但我需要在最后一个网格旁边水平放置一些东西
-
尝试在您的网格中设置
flex: 1可能吗? -
solar:你能分享一些小提琴吗?
-
将 flex 添加到网格工作...谢谢!