如何更改jqgrid的页脚数据的颜色? [英] how can I change the color of footer data of jqgrid?

查看:183
本文介绍了如何更改jqgrid的页脚数据的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jqgrid,并且在页脚有总值显示.我想将负值的颜色转换为红色.我该怎么办?

I have a jqgrid and on footer there are total values displaying. I want to convert the color of negative values to red. How can I do that?

推荐答案

如果使用false作为footerData的最后一个参数,则jqGrid不会格式化数据.因此,您可以使用<span style="color:red">...</span>之类的HTML片段来更改显示数据的颜色.另外,您可以使用ui-state-error之类的jQuery CSS Framework类突出显示文本(请参见答案).

If you use false as the last parameter of footerData the data will be not formatted by jqGrid. So you can use HTML fragments like <span style="color:red">...</span> to change the color of displayed data. Alternatively you can use jQuery CSS Framework classes like ui-state-error to hightlight the text (see the answer).

如果您仍需要格式化汇总值,则可以使用$.fmatter.util.NumberFormat(请参见答案

If you need still format the summary value you can use $.fmatter.util.NumberFormat (see the answer or this one) or use formatter method like in the demo

使用

footerrow: true,
loadComplete: function () {
    var $self = $(this),
        sum = $self.jqGrid("getCol", "amount", false, "sum"),
        i,
        iCol = $("#" + $.jgrid.jqID(this.id) + "_" + "amount")[0].cellIndex, // get index of "amount" column
        sumFormatted = this.formatter("", sum, iCol);

    $self.jqGrid(
        "footerData",
        "set",
        {
            invdate: "Total:",
            amount: sum < 0 ? "<span style='color:red'>" + sumFormatted + "</span>": sum
        },
        false
    );
}

这篇关于如何更改jqgrid的页脚数据的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆