如何在比较数值时呈现Font Awesome图标 – Ext JS

huangapple go评论52阅读模式
英文:

How to render a font awesome icon when comparing from a value - Ext JS

问题

我有一个网格,在网格线上,我想根据条件呈现一个很棒的字体图标。

text: UITEXT.GENERAL_STATUS,
dataIndex: 'status',
sortable: false,
flex: 0.5,
align: 'center',
renderer: function (value, record, dataIndex, cell, column) {
if(value === 1){
return 'x-fa fa-arrow-circle-up';
}else if(value === 3){
return 'x-fa fa-arrow-circle-down';
}
}

英文:

I have a Grid, and on the grid line I want to render an awesome font icon depending on a condition.

text: UITEXT.GENERAL_STATUS,
dataIndex: 'status',
sortable: false,
flex: 0.5,
align: 'center',
renderer: function (value, record, dataIndex, cell, column) {
    if(value === 1){
        return 'x-fa fa-arrow-circle-up';
    }else if(value === 3){
        return 'x-fa fa-arrow-circle-down';
        }
    }
                                                     .                                                  

答案1

得分: 0

根据文档,你需要从 renderer 函数返回以下内容:

<span class="x-fa fa-arrow-circle-up"></span>

如果需要自定义样式,你也可以添加它:

<span style="width:24px;color:red;" class="x-fa fa-arrow-circle-up"></span>
英文:

According to the documentation, you need to return from the renderer function:

>The HTML string to be rendered.

Since FontAwesome icons are referred in Ext JS with CSS styles, you can do the following:

return &#39;&lt;span class=&quot;x-fa fa-arrow-circle-up&quot;&gt;&lt;/span&gt;&#39;;

If you need some custom styling you can add it as well:

return &#39;&lt;span style=&quot;width:24px;color:red;&quot; class=&quot;x-fa fa-arrow-circle-up&quot;&gt;&lt;/span&gt;&#39;;

答案2

得分: 0

我找到了解决方法

text: UITEXT.GENERAL_STATUS,
dataIndex: 'status',
sortable: false,
flex: 0.5,
align: 'center',
renderer: function (value, record, dataIndex, cell, column) {
    cell.setTools({
        name: {
            iconCls: value === 1 ? 'x-fa fa-arrow-circle-up' : 'x-fa fa-arrow-circle-down',
        }
    });
},
英文:

I found a way to solve

text: UITEXT.GENERAL_STATUS,
dataIndex: &#39;status&#39;,
sortable: false,
flex: 0.5,
align: &#39;center&#39;,
renderer: function (value, record, dataIndex, cell, column) {
    cell.setTools({
        name: {
            iconCls: value === 1 ? &#39;x-fa fa-arrow-circle-up&#39; : &#39;x-fa fa-arrow-circle-down&#39;,
        }
    });
},

huangapple
  • 本文由 发表于 2023年8月4日 04:29:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76831438.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定