Passing CSS classes in JSON?

Passing CSS classes in JSON?

alisalaahalisalaah Posts: 2Questions: 0Answers: 0
edited January 2012 in General
I have an application where I believe deferred loading will be best (show 1-25 with the initial html and rendering, then the other 2000+ rows via AJAX)... but one column has a class name to color a positive number green, negative number red and 0 to yellow (this value is a change since earlier so JS alone won't work).

I need a way to format my JSON so that I can insert a class name for a field in the reply.. is there a way to do this?

Replies

  • alisalaahalisalaah Posts: 2Questions: 0Answers: 0
    edited January 2012
    This is the code:

    http://beta.anonpa.com/planets
    JSON @ http://beta.anonpa.com/index/planets/format/json

    Deferred loading, looks fine but messes up once I page or search...
  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    > I need a way to format my JSON so that I can insert a class name for a field in the reply.. is there a way to do this?

    There isn't a built in way to do this in DataTables (i.e. there is no way to target a class at an individual cell using only JSON), but it is perfectly possible to use fnRowCallback to do this, and possibly mDataProp to make life easier when accessing properties ( http://datatables.net/blog/Extended_data_source_options_with_DataTables ).

    Allan
This discussion has been closed.