gpt4 book ai didi

javascript - 如何在 Ext.Panel 标题中放置文本和可点击图标?

转载 作者:数据小太阳 更新时间:2023-10-29 05:13:47 25 4
gpt4 key购买 nike

我想在面板的标题中放置文本和可点击的图标,如下所示: enter image description here

我找到了一些 old hacks from 2008 to do this ,但可以想象,较新版本的 ExtJS 允许您以更直接的方式将文本和图标放在面板标题中。

在 Ext.Panel 标题中放置文本和可点击图标的最直接方法是什么?

附录

感谢@Stefan 的工作,这是我的解决方案:

enter image description here

Javascript:

var grid_shopping_cart = new Ext.grid.GridPanel({
headerCfg: {
tag: 'div',
cls: 'x-panel-header',
children: [
{ tag: 'div', cls: 'panel_header_main', 'html': 'Shopping Cart' },
{ tag: 'div', cls: 'panel_header_icon1', 'html': '<img src="images/icon_plus.png" />' },
{ tag: 'div', cls: 'panel_header_extra', 'html': 'Order Number: 2837428347' }
]
},
width: 600,
height: 390,
...
listeners: {
'afterrender' : function(p) {
p.header.on('click', function(e, h) {
alert('you clicked the plus');
}, p, {
delegate: '.panel_header_icon1',
stopEvent: true
});
},
...

CSS:

div.panel_header_main {
text-align: left;
float: left;
}

div.panel_header_extra {
text-align: left;
float: right;
margin-right: 10px;
}

div.panel_header_icon1 {
text-align: right;
float: right;
margin-left: 3px;
cursor: hand;
cursor: pointer;
}

div.panel_header_icon2 {
text-align: right;
float: right;
margin-left: 3px;
cursor: hand;
cursor: pointer;
}

最佳答案

也许您可以使用 Ext.PanelheaderCfg 配置选项:

...,
headerCfg: {
tag: 'div',
cls: 'x-panel-header',
children: [
{ tag: 'div', cls: 'my-title', 'html': 'Shopping Cart' },
{ tag: 'div', cls: 'my-status', 'html': 'Status: on <img src="status.png" />' }
]
},
...

必须在 afterrender 事件中添加可点击行为,例如:

function(p) {
p.header.on('click', function(e, h) {
}, p, {
delegate: '.my-status',
stopEvent: true
});
}

当然,您需要一些 CSS 来设置标题的样式...

关于javascript - 如何在 Ext.Panel 标题中放置文本和可点击图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4990057/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com