How to sort a rendered numeric column?

How to sort a rendered numeric column?

arslanbenzerarslanbenzer Posts: 1Questions: 1Answers: 0

I put icons to table cells according to numeric values. I use rendering to put icons but after putting icons I am not able to sort the column numerically. What do I do wrong?
If I put "type":"num" the column will not sort, If I don't put it, the colmun will sort lexically. Data that come to render function is like "15.435345".

var dtable = $( '#datatable-responsive-demand' ).dataTable( {
        "ordering" : true,
        responsive : true,
        "order" : [ [ 11, "desc" ] ],
        columnDefs : [ {
            "type" : "date",
            "targets" : [ 11 ]
        },
        {
            //"type": "num",
            "targets" : [ 3 ],
            "render" : function( data, type, full, meta )
            {
                var occasionText = "";
                if ( data > 15 )
                {
                    occasionText = '<img title="<<title>>" src="assets/images/demand/demand_7.png" style="height: 30px;">';
                }
                else if ( data > 12 )
                {
                    occasionText = '<img title="<<title>>" src="assets/images/demand/demand_6.png" style="height: 30px;">';
                }
                else if ( data > 9 )
                {
                    occasionText = '<img title="<<title>>" src="assets/images/demand/demand_5.png" style="height: 30px;">';
                }
                else
                {
                    occasionText = '<img title="<<title>>" src="assets/images/demand/demand_1.png" style="height: 30px;">';
                }

                //occasionText = occasionText.replace( '<<title>>', '%' + Math.round( data ) );
                return occasionText ;
            }
        }]
    } );

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.