Search code examples
jqueryjquery-bootgrid

Custom row color Jquery Bootgrid


Using jQuery Bootgrid, and the "default" status mappings work (success, info, warning, error), but the moment I customize it, it does not. This question's solution does not work in my case: Jquery Bootgrid table row color based on condition

Below is my initialization of the script.

$(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"
        }
    });
});

My data does contain the correct values for the statuses, as follows:

{
    "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"
}

Can someone please advise what I am doing wrong? There are no console errors, and the bootgrid table displays, but won't do the custom colors.


Solution

  • Found the problem: the initialization has to be "statusMapping", not "statusMappings". The plugin's documentation is incorrect: http://www.jquery-bootgrid.com/documentation#statusmappings

    Going to submit a bug report on Github accordingly.