Sorting with render problem
Sorting with render problem
 jaco01            
            
                Posts: 1Questions: 1Answers: 0
jaco01            
            
                Posts: 1Questions: 1Answers: 0            
            I am trying to sort my column with rendered values, but it still order by original data. Can you help me?
Just displaying works fine. Filtering also doesn't work but this is not a problem now.
{"data":0,
    render: function ( data, type, row ) {
            var ms= new Date(row[1]).getTime(); 
            var now = $.now(); 
            var offset = data*24*3600*1000; 
            var rok= (ms+offset)-now;
            if ( type == 'type' || type == 'sort' ){
                return  rok;
            }
            if ( type == 'display' || type == 'filter' ){
                return  Math.round(rok/1000/3600/24) + ' (' + data + ')' ;
            }
    }
},
This discussion has been closed.
            
Answers
Are you changing the value after your DataTable's initial display? After initial display of data, DataTables caches column data for filtering/sorting/etc. So if you change the original value behind a cell, you will need to invalidate the cell and re-render it.
https://datatables.net/reference/api/cell().invalidate()
https://datatables.net/reference/api/cell().render()
Combining these two links would look like this