fixed cell data comparison

fixed cell data comparison

infotbainfotba Posts: 17Questions: 3Answers: 0

Hi,

I want to compare each avarage value with john's age.
if avarage value > John's value avarage value font must red
if avarage value < John's value avarage value font must green

For example
for john ------- 40 > 30 avarege value font red
Marry 35 > 30 font red
Herry 50 > 30 font red
George 20 < 30 font green
Suzan 18 < 30 font green
Alice 60 > 40 font red
Bruce 70 > 30 font red
Tom 10 < 30 font green

Thank you.

http://live.datatables.net/mayasike/1/edit

Replies

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    The rowCallback option is one way to achieve this. Please post an updated example if you need help with getting it working.

    Kevin

  • infotbainfotba Posts: 17Questions: 3Answers: 0
  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945
    edited May 2018

    Here is an example:
    http://live.datatables.net/mayasike/4/edit

    Kevin

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    Sorry, back tracked and found your attempts. I think this example is more what you are looking for:
    http://live.datatables.net/jiteyura/1/edit

    Kevin

  • infotbainfotba Posts: 17Questions: 3Answers: 0

    This example for same row data. But my fixed value is = 30
    all age data mus be compere with 30

  • infotbainfotba Posts: 17Questions: 3Answers: 0

    sorry avarage data mus be compere with 30

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    There is not much difference in the code but my first example compares to 30:
    http://live.datatables.net/mayasike/4/edit

    Kevin

  • infotbainfotba Posts: 17Questions: 3Answers: 0

    You are right. But 30 is fixed in your example. But I have get the value( Johns' age) with a code. Because it may change

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    I'm not totally clear what you want to do. Maybe you can update one of my examples with what you want and if you still have questions post an explanation with the link to your updated example.

    Kevin

  • infotbainfotba Posts: 17Questions: 3Answers: 0

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    Ok, that helps. How are you deciding to compare with John versus the others?

    Kevin

  • infotbainfotba Posts: 17Questions: 3Answers: 0

    I try to explain
    I have to get  John s' age .It will be my fixed value.( In the example 30). Name of John will be always in my other several json file.Because its' age  is a kind of my secret key.

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    Is it possible to return the value of John's age in each row of data from your server script? If so then the data can easily be accessed but you don't need to display it in the table.

    Are you using arrays or objects?

    Are you using ajax to get the data?

    The more specific you can be about your data, data structures, etc the easier it will be to help.

    Kevin

  • infotbainfotba Posts: 17Questions: 3Answers: 0

    about my project:

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    How and when do you decide to compare John's age? Answering this will help determine where to get the age from.

    Is it always John?

    Can the user select John or another student to compare ages?

    Can there be more than one John?

    Kevin

This discussion has been closed.