ExtJS4树形面板图标问题
我们在应用程序中使用树面板。代码是:
var exStore = Ext.create('Ext.data.TreeStore',{
root : {
children : [{
text : 'Parent 1',
id : 'parent1',
checked : false,
iconCls : 'ico1',
children : [{
text : 'Child 1',
id : 'child1',
checked : false,
leaf : true
},{
text : 'Child 2',
id : 'child2',
checked : false,
leaf : true
}]
},{
text : 'Parent 2',
id : 'parent2',
checked : false,
iconCls : 'ico2',
children :[{
text : 'Child 3',
id : 'child3',
checked : false,
leaf : true
},{
text : 'Child 4',
id : 'child4',
checked : false,
leaf : true
}]
}]
}
});
var treepanel = Ext.create('Ext.tree.Panel',{
id : 'tree',
width : 300,
height : 300,
store : exStore,
rootVisible : false
});
但我们在这里面临两个问题。
1.我们为父节点指定了 iconCls。当树折叠时它显示正常。如果我们展开树,它会被文件夹图标替换。作为参考,请查看附图。
2.如果选择父节点,则必须选择特定父节点下的子节点。
如果有人有想法。请帮助我。我们在这些问题上做了很多尝试。
We are using treepanel in our application.The code is:
var exStore = Ext.create('Ext.data.TreeStore',{
root : {
children : [{
text : 'Parent 1',
id : 'parent1',
checked : false,
iconCls : 'ico1',
children : [{
text : 'Child 1',
id : 'child1',
checked : false,
leaf : true
},{
text : 'Child 2',
id : 'child2',
checked : false,
leaf : true
}]
},{
text : 'Parent 2',
id : 'parent2',
checked : false,
iconCls : 'ico2',
children :[{
text : 'Child 3',
id : 'child3',
checked : false,
leaf : true
},{
text : 'Child 4',
id : 'child4',
checked : false,
leaf : true
}]
}]
}
});
var treepanel = Ext.create('Ext.tree.Panel',{
id : 'tree',
width : 300,
height : 300,
store : exStore,
rootVisible : false
});
But we are facing two issues here.
1.We have specified iconCls for parent node.It is displaying fine when tree collapsed.If we expand the tree it is replaced with folder icon.For reference please have a look at attached images.
2.If we select the parent node,then the child nodes under particular parent nodes has to getselected.
If any one has idea.Please help me.We are trying a lot on these issues.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
转到你的 css 并尝试类似的操作:
Go to your css and try something like :
您可以通过列出树的“cls”属性来指定要应用图标更改的树。例如:
这样,包含树面板的 DIV 将应用 CSS 类“my-tree-panel”。然后在您的 css 文件中定义选择器,如下所示:
图标更改将仅应用于该特定的树面板。因此,您可以在应用程序中拥有不同的树面板,并且可以为每个面板自定义图标。
You can specify which tree you want the icon change to apply by listing the 'cls' property of the tree. For example:
With that, the DIV that contains the tree panel will have the CSS class 'my-tree-panel' applied to it. Then in your css file define the selector as follows:
The icon change will be applied only to that particular tree panel. Thus, you can have different tree panels in your applications and you'll be able to customize the icons for each.
更改树的图标,然后给出其 Id,就像
您想要任何特定图标的图标,然后给出该节点 Id 一样,同样可以正常工作。
to change icon for tree then give its Id as
if you want icon for any particular icon then give that node Id, the same works fine.