Column ordering problem

Column ordering problem

aegnaegn Posts: 1Questions: 0Answers: 0
edited April 2011 in Bug reports
In DataTables, the column re-ordering routine assumes that server returns exactly the same columns, as configured in aoColumns array, but in arbitrary order. In real life, however, it is convenient for server to be able to return any set of columns. Some columns configured in aoColumns may be absent and some other columns may exist in the dataset returned by server. So, in my situation, I had to slightly modify the function:
[code]
// Original code:
function _fnReOrderIndex ( oSettings, sColumns )
{
var aColumns = sColumns.split(','); // returned from server
var aiReturn = [];

for ( var i=0, iLen=oSettings.aoColumns.length ; i

Replies

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin
    Hi aegn,

    Thanks very much for the code change. It's an interesting idea certainly. The approach I've generally taking is that, if there is a column in the table, it _must_ be defined in the data source - otherwise you will get 'undefined' or null or something shown in the table, which most people, I believe, would not want.

    Having said that, I'm in the middle of making some changes for 1.8 which will greatly improve the flexibility provided, giving the ability to not return the full set required (although again, DataTables will give an error if it tries to access a property which does not exist).

    Regards,
    Allan
This discussion has been closed.