how can I change the color of footer data of jqgrid?

醉酒当歌 提交于 2020-01-06 13:51:57

问题


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?


回答1:


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).

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

which uses

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
    );
}


来源:https://stackoverflow.com/questions/19240335/how-can-i-change-the-color-of-footer-data-of-jqgrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!