arrayNotation + sorting?
arrayNotation + sorting?
g100
Posts: 2Questions: 1Answers: 0
I am using array notation for a column:
e.g. data: "Nickname[, ].name"
which outputs a series of nicknames separated by columns, like "Jimmy, Jones, JJ"
Is array notation supported for sorting by that column?
This discussion has been closed.
Answers
It will sort based on the column (i.e. vertically down the rows) but it will not sort the data that is displayed in each cell - it will display in index order (for example you might have "Jimmy, Allan" rather than "Allan, Jimmy" as it would be sorted alphabetically).
If you want to sort the data in each cell you would need to use
columns.render
as a function, pluck out the data you want, sort it and then return the concatenated string. So it is still perfectly possibly, it just required a couple of lines of code.Allan
Thanks. This only works in 1.10 right? I'm looking at an ajax query for pagination that passes on the sort as "Nickname[, ].name". I would note that the code I'm working with is using "sAjaxSource" which I see triggers the older behavior.
Yes. It might be possible to do it in legacy methods - I can't remember, its been such a long time since I used 1.9! 1.10 would be my recommendation.
I guess you are using server-side processing (a link to the page, per the forum rules, would let me gain this information)? If so, I don't really see that would make any difference. You can still use
columns.render
to sort the data in the cell. Assuming I've understood the issue correctly.Allan