Sorting DataTable
Sorting DataTable

Hi all,
I am have a column that has an integer value. Depending on the value I am render a string instead.
When I am trying to sort this column it seems it use the render value for sorting. Is there the posibility to use the data behind for rendering?
e.g.:
data: 1 => render: "Rahmenprofil"
data: 2 => render: "Rahmenteil"
data: 3 => render: "Flügelprofil"
data: 4 => render: "Flügelteilt"
I am using:
order: [
[11, "asc"]
]
but I get as result
Rahmenteil
Rahmenprofil
Flügelteil
Flügelprofil
I hope some one can help me to get the right ordering for my data.
Thanks a lot for any advice
Arga
Answers
Hi @ArgaWoW ,
There are a couple of ways that you could do this. You could use
columns.render
to set the data for thesort
property there. You could also create a sorting plugin to identify the numbers and then return the relevant data, take a look at this example which is doing something similar.Thanks,
Sandy
Hi @sandy,
thank you very much for your answer.
I will try the plugin
Perhaps,
please can you give me an example how to do the ordering within the Columns.Render option. ?
Thanks a lot again
CU Araga
Here's an example of that ordering,
Colin
Hi Colin,
thanks a lot for you answer, but it dont work for me.
Here is my code:
` columnDefs: [
`
I have add a log to the console, but it seems the code dont enter the function.
Any idea?
Again, thanks for your help
Arga
Could you give us a link to your page - that looks like it should work. Unless you are using server-side processing perhaps? If you are (
serverSide
), then whatever script you are using at the server-side is responsible for doing the sorting.Allan
Hi Allan,
whats the ways you would access my side?
Would you accept an teams sessions to look on my maschine?
Would be the easiest and fastest way to show you my code
If you agree, sen me a pm
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin