loading data from an attribute.

loading data from an attribute.

petterpetter Posts: 8Questions: 0Answers: 0
edited March 2009 in General
I have tested the follwing approch for sorting/filtering in datatables..

in the function gatherData aprox line 1430 in the 1.4 file.

aLocalData[i] = this.innerHTML;
aLocalData[i] = this.getAttribute("sortData") || this.innerHTML;

That way I can put 'any type' of data in the td and still do sorting.
data could be image/currency/dates..

ofcourse there will be som issues regarding filter, but that might be solved in another way..

is not recognized as a date, so this collumn will be considerd a string in datatables..
the 'date' is now an integer, and sorts as expected.

Any comments?


  • allanallan Posts: 57,236Questions: 1Answers: 9,113 Site admin
    Hi Petter,

    Thanks for your suggestion, however as we talked about off the forum, my preference for this would very much be to use a sorting plug-in (that's what they are there for after all!). As you note, this method of changing what aLocalData is actually reading is going to give significant issues with the filtering. It also doesn't put any onus on the server to produce invalid HTML.

This discussion has been closed.