Adding css class to rows - server side

Adding css class to rows - server side

b0b3kb0b3k Posts: 2Questions: 0Answers: 0
edited August 2011 in General
I have an problem. I'm using DataTables with server-side version. I've added smth like "priority" to projects, each one have a "color" - red is most important of them.. i'm selecting it from mysql.

It looks like this:
table projects, id, title, date, and priority

priority
1 - red
2- light red
3- green
4- light green

And i would like to get this from mysql and add to " when I'm getting it to datatables - is it possible ?

Replies

  • b0b3kb0b3k Posts: 2Questions: 0Answers: 0
    Ok i found this:

    [code]
    for ( var i=0, iLen=oSettings.aoData.length ; i
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited August 2011
    no problem, but it is also possible to have your server side script add row-level classes.

    see DT_RowClass on http://www.datatables.net/usage/server-side


    [code]
    {
    "sEcho": 3,
    "iTotalRecords": 57,
    "iTotalDisplayRecords": 57,
    "aaData": [
    {
    "DT_RowId": "row_7",
    "DT_RowClass": "gradeA",
    "0": "Gecko",
    "1": "Firefox 1.0",
    "2": "Win 98+ / OSX.2+",
    "3": "1.7",
    "4": "A"
    },
    {
    "DT_RowId": "row_8",
    "DT_RowClass": "gradeA",
    "0": "Gecko",
    "1": "Firefox 1.5",
    "2": "Win 98+ / OSX.2+",
    "3": "1.8",
    "4": "A"
    },
    ...
    ]
    }
    [/code]
    (I'm not sure if you need to use objects instead of arrays to make this work, but i think you do, else how/where would you specify DT_RowClass?)
This discussion has been closed.