1

I am using YUI2 datatable. consider the following scenario.

var myColumnDefs = [ 
                { key:"A", label:"A", sortable:true},
                { key:"C", label:"C", sortable:true}
            ];


   // i want to add this column after A.
   myColumnDefs.push({ key:'B',label:'B'});

this code will generate columns A,C,B but i want it to be A,B,C. how can i do it?

vinesh
  • 4,745
  • 6
  • 41
  • 45

1 Answers1

1

You can sort the columns definition before passing them to the yui datatable constructor:

myCOlumnDefs.sort(function(c1, c2){

return c1.key > c2.key ? 1 : -1;

});