将css类添加到Ext.view.view Extjs 4中的节点
我正在尝试将css类添加到Ext.view.view的节点中。我使用它列出视图中的N个div,并使它们可以选择。当选择这些div中的一个时,它应该更改颜色以标识它已被选中将css类添加到Ext.view.view Extjs 4中的节点,css,extjs4,nodes,Css,Extjs4,Nodes,我正在尝试将css类添加到Ext.view.view的节点中。我使用它列出视图中的N个div,并使它们可以选择。当选择这些div中的一个时,它应该更改颜色以标识它已被选中 Ext.create('Ext.view.View', { store: ... tpl: ... multiSelect: true, height: 310, trackOver: true, overItemCls: 'cell-wrap-hover', itemS
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]
}
}
}
}
一旦我添加了这个新类并保留了其他类,我就可以使用新类名作为选择器,对于视图中的选定项,也可以使它们看起来不同。我自己找到答案:在tpl中,我为DIV选择器添加了一个ID,比如:ID=cell-X,其中X是一个索引0,1,2。。。。 然后在foreach中,我使用命令行在选定节点上添加类:
Ext.get('cell-' + nodes[i].index).addCls('cell-wrap-selected');
塔克斯