Slow work of coloring of rows

Slow work of coloring of rows

qweqweqweqwe Posts: 4Questions: 0Answers: 0
edited August 2012 in General
Hi all.

I have MySQL base which consists of 1500 entries. I want to make different color of rows and do it like this:
[code]"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
if(aData[1].search("black")>-1){
$(nRow).addClass("black");
}[/code]

But the problem is that it is so slow and my base loads only when I select to show no more than 100 entries.
What i should do to make my table more fast? :)

Replies

  • qweqweqweqwe Posts: 4Questions: 0Answers: 0
    [code]
    "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
    if (aData[1]=="black") {nRow.className = nRow.className + "black"}
    if (aData[1]=="yellow") {nRow.className = "yellow"}
    if (aData[1]=="red") {nRow.className = "red"}
    if (aData[1]=="green") {nRow.className = "green"}
    },
    [/code]

    Yeah. I made it ;)
  • qweqweqweqwe Posts: 4Questions: 0Answers: 0
    New problem...

    I want to make class of row "even black". Now I have the class like this only for black, other classes look like " green", " yellow"... What I should do?
  • qweqweqweqwe Posts: 4Questions: 0Answers: 0
    New problem....new solution. It was easy :)
    [code]
    "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
    if (aData[1]=="black") {nRow.className = nRow.className + " black"}
    else if (aData[1]=="yellow") {nRow.className = nRow.className + " yellow"}
    else if (aData[1]=="red") {nRow.className = nRow.className + " red"}
    else if (aData[1]=="green") {nRow.className = nRow.className + " green"}
    },
    [/code]
This discussion has been closed.