Order by
Order by

I am having trouble figuring out how to order by just numbers only.
I would like DataTables to ignore ordering by stock_code and only sort by stock_number is row stock_number
Any help is appreciated!
"order": [[ 0, "desc" ]],
"columns": [
{
"data": "stock_number",
render: function ( data, type, row ) {
return row.stock_code+ +row.stock_number;
}
},
{ "data": "year" },
{ "data": "make" },
{ "data": "model" },
{ "data": "date" },
{ "data": "vin" },
{ "data": "miles" },
{ "data": "cost" },
{ "data": "who" }
]
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Not sure what the data looks like but maybe you can use the Natural sorting plugin.
Kevin
Sorry "stock_code" is letters and "stock_number" is numbers only. I would like it to only sort by numbers and ignore all letters.
Try the Natural sorting plugin. It works for me to sort data in that format,
Kevin
The other option would be to use the rendering function to make use of DataTables' orthogonal data:
Allan