Sorting & HTML

Sorting & HTML

polskikrolpolskikrol Posts: 10Questions: 0Answers: 0
edited April 2011 in Bug reports
When sorting a column, the data has HTML which allows for cell shading to provide a status (RAG - Red, Amber, Green). Appears that when the column is clicked to sort, the HTML is stripped, and then sorted. However, following the sort, the HTML stripped data is used and not the original data.

Would there be any way to change this behavior?

Replies

  • GregPGregP Posts: 500Questions: 10Answers: 0
    I can't answer your actual question, I'm afraid. Not sure about any HTML stripping.

    But I thought I would mention that I do something very similar (keep a status) in my application. Instead of sending it in an HTML string, I keep the status in a separate column, which is hidden. Then using the fnRowCallback, I check the corresponding column in the data object for the status and perform some logic based on what I find.

    It's good design to separate the visual element from the data element (in an MVC model, separating the Model from the View), so in my opinion it's worth changing the way data is stored and sent, rather than working around the HTML. I'm happy to help out if you decide to go that way.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You can set the sType for the column to 'string'. That will keep the HTML in the sort.

    Allan
  • polskikrolpolskikrol Posts: 10Questions: 0Answers: 0
    As a follow-up, there were a few issues which I resolved:
    (1) Modified CSS so that column select for sort did not alter the column shading, preserving the RAG status.
    (2) Altered source XML being parsed with PHP to include a 'data type', equivalent to sType. Added a few extensions to the sType for handling numerics with html, IP addresses with html, and percentages with html. So upon sorting, the proper stripping of HTML (and percentage signs where appropriate) is performed and casting to the desired datatype to sort upon.
This discussion has been closed.