How to add data-order attribute when building data tables dynamically

How to add data-order attribute when building data tables dynamically

kulkarni_ashkulkarni_ash Posts: 35Questions: 8Answers: 0
edited October 2016 in Free community support

Hi
How to add data-order attribute or some other HTML5 attributes when building table dynamically
This is what i am have so far, i want to add data-order to 6th column, since i am converting this numeric value to text.

var table = $(tableId).DataTable(
            {
                "destroy": true,
                "responsive": true,
                "bProcessing": true,
                "bDeferRender": true,
                                "paging": true,
                                 "aaData": tableData, 
                  "aoColumns": tableHeader,
                  "columnDefs": [
                                     {
                                        
                                     "render": function ( data, type, row ) {
                                         if(data > -1){
                                        return  data.format(2,3,',','.');   
                                            
                                        }
                                        else{
                                            return "<span style=\"color:red\">( " + Math.abs(data).format(2,3,',','.') + " )</span>";   
                                             
                                        }
                                     },
                                     "targets": 6
                                 }
                             ],
            }
            );
This discussion has been closed.