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;
With
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..
exampel

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

Any comments?

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 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.

    Allan
This discussion has been closed.