1

我正在使用 YUI2 数据表。考虑以下情况。

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'});

此代码将生成列 A、C、B,但我希望它是 A、B、C。我该怎么做?

4

1 回答 1

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;

});

于 2014-03-26T22:18:39.823 回答