自定义行颜色Jquery Bootgrid

时间:2016-07-20 17:55:19

标签: jquery jquery-bootgrid

使用jQuery Bootgrid,“默认”状态映射工作(成功,信息,警告,错误),但是当我自定义它时,它没有。这个问题的解决方案在我的案例中不起作用:Jquery Bootgrid table row color based on condition

以下是我对脚本的初始化。

$(document).ready(function(){
    $("#client_list").bootgrid({
        css: {
            icon: "zmdi icon",
            iconColumns: "zmdi-view-module",
            iconDown: "zmdi-sort-amount-desc",
            iconRefresh: "zmdi-refresh",
            iconUp: "zmdi-sort-amount-asc"
        },
        ajax: true,
        post: function(){
            return { id: "b0df282a-c9e93b7befee" };
        },
        url: "get_logview/client/client",
        caseSensitive: false,
        selection: false,
        multiSelect: true,
        rowSelect: true,
        searchSettings: {
            delay: 100,
            characters: 3
        },
        keepSelection: true,
        statusMappings: {
            4: "loglow",
            5: "logmediumlow",
            6: "logmedium",
            7: "logmediumhigh",
            8: "loghigh",
            9: "logcritical",
            10: "logcatastrophic"
        }
    });
});

我的数据确实包含状态的正确值,如下所示:

{
    "current": 1,
    "rowCount": "10",
    "rows": [
        {
            "id": "1",
            "type": "Notice",
            "message": "User 127.0.0.1 (User ID: 1) accessed the logs.",
            "impact": "Low",
            "user": "127.0.0.1 (User ID: 1)",
            "createdate": "2016-07-20 19:39:03",
            "status": 4
        },
        {
            "id": "2",
            "type": "Notice",
            "message": "User 127.0.0.1 (User ID: 1) accessed the logs.",
            "impact": "Low",
            "user": "127.0.0.1 (User ID: 1)",
            "createdate": "2016-07-20 19:39:03",
            "status": 4
        }
    ],
    "total": "2"
}

有人可以告诉我我做错了什么吗?没有控制台错误,并且显示bootgrid表,但不会执行自定义颜色。

1 个答案:

答案 0 :(得分:3)

发现问题:初始化必须是“statusMapping”,而不是“statusMappings”。该插件的文档不正确:http://www.jquery-bootgrid.com/documentation#statusmappings

相应地提交关于Github的错误报告。