Im using DataTables jQuery plugin for my table. The problem is some column in my table contains text and number (like: 5 Pieces
, 2 Pieces
, 20 Pieces
). The DataTables plugin automatically sorts these rows like this:
- 2 Pieces
- 20 Pieces
- 5 Pieces
While I need it to be sorted like this:
- 2 Pieces
- 5 Pieces
- 20 Pieces
When I removed the 'Pieces' string, it worked well, but I need to use the word 'Pieces'. Can someone help? Thanks a lot..
Sorry for the same question, i tried this fiddle and it works well, but somehow, i'm using a template for the HTML and CSS which includes this datatables plugin..
and the js code is written like this (this code format works well, but i cant use the formatted-num extended plugin with this format):
var initTable40 = function () {
var table = $('#sample_40');
var oTable = table.dataTable({
"columnDefs": [{
"orderable": true,
"targets": [0]
}],
});
while in the jsfiddle (which is the one working) written like this:
$('#sample_40').dataTable( {
columnDefs: [
{ type: 'formatted-num', targets: 0 }
]
} );
i tried to do this but it wont work as well:
var initTable40 = function () {
var table = $('#sample_40');
var oTable = table.dataTable({
"columnDefs": [{
"type": "formatted-num",
"targets": [0]
}],
});
or tried to do this wont work as well too:
var initTable40 = function () {
var table = $('#sample_40');
var oTable = table.dataTable({
"columnDefs": [{
"orderable": true,
"targets": [0]
},{
"type": "formatted-num",
"targets": [0]
}],
});
thanks for help!