Quantcast
Viewing all articles
Browse latest Browse all 82152

oColReorder with aiOrder option not reordering table data

Hi,

Datatables is awesome!

I am facing an issue with reordering columns though. I wanted to predefine a column order for the table.
But only the table headers get reordered according to the indexes specified in "aiOrder".

I make an AJAX call which returns a csv file and use fnAddData to add the rows to the datatable.
I have placed the code for reordering the columns after the AJAX call and aoColumns:
$(document).ready(function(){
	                      
				$.ajax({
				type: "GET",
				url: "/abc",
				dataType: "text",
				success: function(data){
				var records=$.csv.toArrays(data);
				for(i=1; i<records.length; i++){
					$('#t-table').dataTable().fnAddData(records[i]);
				}		
			}
		});	
                               var oTable= $('#txnTable').dataTable( {		
               			"sDom": 'Rlfrtip',						 
				 "bJQueryUI": true,
				 "sPaginationType": "full_numbers",				
				"aoColumnDefs": [
				{						
					"aTargets": [5],
					"bUseRendered": false,
					"fnRender": function(o){
					return 	o.oSettings.fnFormatNumber(parseFloat(o.aData[o.iDataColumn]));
				        }
							
				}					
			  ],
			               "aoColumns": [				
						
						{ "sTitle": "col1" },					
						{ "sTitle": "col2" },
						{ "sTitle": "col3" },												
						{ "sTitle": "col4" },
						{ "sTitle": "col5" },
						{ "sTitle": "col6", "sType": "numeric" },
                                           ],
                                       "oColReorder": {
						"aiOrder": [0,1,2,6,5,4,3]
					}
					
				} );

Please help!
I cannot for the life of me figure out what's going wrong.
I am only able to move the columns around by dragging them.

Viewing all articles
Browse latest Browse all 82152

Trending Articles