gpt4 book ai didi

css - 将 css 类添加到 Ext.view.View Extjs 4 中的节点

转载 作者:行者123 更新时间:2023-11-28 14:25:01 25 4
gpt4 key购买 nike

我正在尝试将一个 css 类添加到 Ext.view.View 中的节点。我用它在 View 中列出 N 个 div 并使它们可选择。当选择这些 div 之一时,它应该更改颜色以标识它已被选中。

Ext.create('Ext.view.View', {
store: ...
tpl: ...
multiSelect: true,
height: 310,
trackOver: true,
overItemCls: 'cell-wrap-hover',
itemSelector: 'div.cell-wrap',
emptyText: 'No item to show',
plugins: [
Ext.create('Ext.ux.DataView.DragSelector', {})
],
listeners: {
selectionchange: function(dv, nodes){
if (nodes.length > 0) {
for (var i in nodes) {
//Here i would like to add one more css class to the nodes[0]
}
}

}
}

一旦我添加了这个新类,并保留了其他类,我就可以使用新类名作为选择器,对于 View 中的选定元素,也可以使它们看起来不同。

最佳答案

我自己找到了答案:在 tpl 中,我为 DIV 选择器添加了一个 ID,例如:id="cell-X",其中 X 是一个索引 (0,1,2...)。然后进入 foreach 我使用命令行在选定节点上添加类:

Ext.get('cell-' + nodes[i].index).addCls('cell-wrap-selected');

谢谢

关于css - 将 css 类添加到 Ext.view.View Extjs 4 中的节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8085448/

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