Just discovered this. Great job! Doing html sorting on a table. Is there built in way to trim leading white spaces in the td cells after the html has been removed?
Are you using the 1.8 beta? I think I might have a small regression issue there - I've not a note to myself to look at that tomorrow morning :-). That should certainly be reverted back to the 1.7 trimming behaviour.
It looks fine to me in both 1.8 beta 3 and 1.7.6 - when reading from the HTML source the data is being trimmed so white space shouldn't matter. Can you give us a link to your example which isn't working please?
Thank you for that - I see what the problem is. DataTables is trimming the data prior to the sort parsing (the removal of the HTML) so if your space was on the other side of the P tag it would be removed - but it's being considered part of the data here - hence the sorting order.
Id suggest having a custom sorting function ( http://datatables.net/plug-ins/sorting ) which does the same as the DataTables default string sort, but adds a $.trim() call - or even use a plug-in to replace the default string sorting. I don't particularly want to add that into the DataTables core since it's extra overhead that won't be used the majority of the time (this is the first time I've come across this issue).
In 2.x I plan to have a callback to make this kind of this a little easier - but that's probably a good little while away :-)
Replies
Allan
I end up with a td tag that looks something like this:
[code]
word
[/code]
That leading whitespace messes up the sorting.
Thanks!
Allan
PA-10-064
There is an extra whitespace after the tag. It sorts correctly after it's removed. Thanks!
[code]
one
two
three
four
BAA -- Broad agency announcements are not included in this list. Find them here: NIAID Solicitations.
DAIDS, DAIT, DMID
Contract
N/A
PA-10-064, NIH Small Research Grant Program (Parent R03)
NIAID Statement of Interest. May change; check the latest version.
DAIDS, DAIT, DMID
R03
Standard dates through
2013-01-08.
RFP -- Requests for proposals are not included in this list. Find them here: NIAID Solicitations.
DAIDS, DAIT, DMID
Contract
N/A
BAA -- Broad agency announcements are not included in this list. Find them here: NIAID Solicitations.
DAIDS, DAIT, DMID
Contract
N/A
[/code]
Thanks!
Id suggest having a custom sorting function ( http://datatables.net/plug-ins/sorting ) which does the same as the DataTables default string sort, but adds a $.trim() call - or even use a plug-in to replace the default string sorting. I don't particularly want to add that into the DataTables core since it's extra overhead that won't be used the majority of the time (this is the first time I've come across this issue).
In 2.x I plan to have a callback to make this kind of this a little easier - but that's probably a good little while away :-)
Allan