如何删除 extjs 树中的图标

发布于 2024-11-18 15:11:16 字数 45 浏览 5 评论 0原文

我想删除 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

放血 2024-11-25 15:11:16

ExtJS 依赖 CSS 进行样式设置,因此删除图标的最简单方法是创建一个 CSS 规则来覆盖 Ext 提供的规则。

这将完成这项工作:

.x-tree-icon { display: none !important; }

添加一个带有 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 :

.x-tree-icon { display: none !important; }

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.

一紙繁鸢 2024-11-25 15:11:16

在列定义中:

columns: [{
    xtype: 'treecolumn',
    text: 'Task',
    iconCls: '', // This property to get rid of tree icon
    width: 200,
    sortable: true,
    dataIndex: 'someStringIdentifier',
    locked: true
}

In the column definition:

columns: [{
    xtype: 'treecolumn',
    text: 'Task',
    iconCls: '', // This property to get rid of tree icon
    width: 200,
    sortable: true,
    dataIndex: 'someStringIdentifier',
    locked: true
}
樱娆 2024-11-25 15:11:16

下面是我使用 ExtJS 6.5 的解决方案,它带来了 2 个优点:

  • 仅关注某些类型的节点,
  • 以避免触发器和

我在 Model 中定义的文本之间存在空格,计算出的 iconCls 返回自定义 css 类:

{
    name: 'iconCls',
    calculate: function (data) {
        return 'uw-shrink-icon';
    }
}

然后在 sass 文件中,我利用本机 x-tree-icon-custom css 类将宽度设置为 0:

.x-tree-icon-custom.uw-shrink-icon {
    background-image: none;
    width:0px;
}

Below my solution with ExtJS 6.5 that brings 2 advantages:

  • to focus on certain types of nodes only
  • to avoid the space between the trigger and the text

I define in the Model a calculated iconCls returning a custom css class:

{
    name: 'iconCls',
    calculate: function (data) {
        return 'uw-shrink-icon';
    }
}

Then in the sass file I take advantage of the native x-tree-icon-custom css class to set the width to 0:

.x-tree-icon-custom.uw-shrink-icon {
    background-image: none;
    width:0px;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文