如何删除 extjs 树中的图标
我想删除 extjs 树中的图标。相反,我想将所有有子节点的节点设置为粗体。
I would like to get rid of the icons in an extjs tree. Instead i would like to set all the nodes that have children in bold.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ExtJS 依赖 CSS 进行样式设置,因此删除图标的最简单方法是创建一个 CSS 规则来覆盖 Ext 提供的规则。
这将完成这项工作:
添加一个带有
extraCls
配置选项的类,或者在必要时使用组件 ID 来限定规则。至于粗体文本,似乎没有办法只使用 CSS,因此您可以监听树视图的 afterRender 事件,尽管如果动态添加节点,这还不够。
ExtJS relies on CSS for styling, so the easiest way to remove the icons is to create a CSS rule that overrides one provided by Ext.
This will do the job :
Add a class with the
extraCls
config option or use the component ID to qualify the rule if necessary.As for the bold text, there doesn't seem to be a way using just CSS, so you could listen to the afterRender event of the tree view, though that won't be enough if you add nodes dynamically.
在列定义中:
In the column definition:
下面是我使用 ExtJS 6.5 的解决方案,它带来了 2 个优点:
我在 Model 中定义的文本之间存在空格,计算出的
iconCls
返回自定义 css 类:然后在 sass 文件中,我利用本机
x-tree-icon-custom
css 类将宽度设置为 0:Below my solution with ExtJS 6.5 that brings 2 advantages:
I define in the Model a calculated
iconCls
returning a custom css class:Then in the sass file I take advantage of the native
x-tree-icon-custom
css class to set the width to 0: