Highlight one row when adding data

Highlight one row when adding data

sckeelssckeels Posts: 3Questions: 0Answers: 0
edited August 2011 in General
Hello,

I need to highlight a row when data is loaded if it meets certain requirments. I am using the following to load data: I am also testing for a certain value (if (carId == carIdtext)). If the condition is true, I need to highlight that row using css. Any assistance would be appreciated.

Regards, Steven

var carIdtext = $("#_CarIdLabel").text();

success: function (data) {
$(data).each(function (key, val) {
var carId = val["CarBrandId"];
var mfr = val["CarManufactureName"];
var car = val["CarBrandName"];

oTable.fnAddData([
val["CarBrandId"],
val["CarManufactureFx"],
val["CarManufactureName"],
val["CarBrandName"]
]);

if (carId == carIdtext) {

}

});
}

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    fnAddData returns an int (or array of ints) of rows added. I think you can use fnGetNodes() to get that TR and add a css class to it

    [code]

    iRow = oTable.fnAddData([
    val["CarBrandId"],
    val["CarManufactureFx"],
    val["CarManufactureName"],
    val["CarBrandName"]
    ]);

    if (carId == carIdtext) {
    oTable.fnGetNodes(iRow).addClass("classname");
    // oTable.fnGetNodes(iRow).css("background-color", "LightPink"); // change to any color you like, or add a class name
    }[/code]
  • sckeelssckeels Posts: 3Questions: 0Answers: 0
    Thank you fbas, this greatly helped. I needed to add the row for my case.

    Also, I could use .addClass, but not .css. If you have any insight on this, that would help for my notes.

    if (carId == carIdtext) {
    var rowI = iRow[0];
    var nNodesI = oTable.fnGetNodes(rowI);

    $(nNodesI).addClass('hilite');

    //$(nNodesI).css("color", "red");
    //$(nNodes).css("background-color:rgb(15,99,30);");
    };

    Regards, Steven
This discussion has been closed.