DataTables v1.9 RowReordering with mDataProp, issue when reordering Columns

DataTables v1.9 RowReordering with mDataProp, issue when reordering Columns

cbapiazcbapiaz Posts: 1Questions: 0Answers: 0
edited April 2012 in DataTables 1.9
This is an issue i just come across, when trying to use row reordering together with col reordering, and i'm using mDataProp with server side sAjaxSource for binding the data.
That means no indexed columns so here comes the problem, it seems that the row reordering pluging strongly uses indexed columns for grouping, and this does not bode well with my column reordering, since for instance if i use this code:

[code]
oTable = oTable.rowGrouping({ bExpandableGrouping: true
, iGroupingColumnIndex: 4
})
//oTable previously initialized datatable
[/code]

Everything works perfectly until i reorder the column at index 4 and put in in another place, now when i search again (rebind the datatable with server data), it takes the column that is now at index 4 and not the column i want it to take.

So i figured a work around to this issue (maybe there's a better solution out there i'm just pointing out the issue).
I had to modify the plugin a bit to get the column index by the mDataProp property, so instead of passing the index directly i pass another property (added by me) named "iGroupingColumnDataProp"
Sample:
[code]
oTable = oTable.rowGrouping({ bExpandableGrouping: true
/* iGroupingColumnIndex: 4 not using column index */
,
iGroupingColumnDataProp: 'cl_nom' // instead directly use the named _mDataProp property
})
[/code]

I made this modifications to the rowGrouping plugin

[code]
....
return this.each(function (index, elem) {

var oTable = $(elem).dataTable();

/**** THIS IS NEW ****/
var oSettings = oTable.fnSettings();
options.iGroupingColumnIndex=getColIndexFromProp(oSettings.aoColumns,options.iGroupingColumnDataProp); // custom function that searches the array and returns first index matching mDataProp with iGroupingColumnDataProp
/*********************/
....
[/code]

Just wanted to point this out, and to discuss if there's not a better solution to this problem or maybe somebody already figured this out, i just couldn't found it anywhere so i did it myself.

Sebastian
This discussion has been closed.