ColReorder returns original columnIndex on sorting
ColReorder returns original columnIndex on sorting
martinvdpoel
Posts: 2Questions: 0Answers: 0
Hi there,
First of all, kudo's for Datatables, imho the best grid there is!
When i enable the colreorder plugin it does reorder the columns perfectly, except when sorting it returns the original index.
I tried the stable and the nightly from this site and the latest from github. Also tried other variants like colreorder with resize. The all do the initial reordering just fine, but on sort it always gives the original column index.
I'm using datatables 1.9.4 and colReorder 1.0.8 - 1.1.0-dev both give the same problem.
[code]
var oTable;
oTable = $("#todo").dataTable({
"sDom": "RC<'row'<'span6'l>f<'span6'>r>t<'row'<'span6'i><'span6'p>>",
"oLanguage": {
"sLengthMenu": "_MENU_ records per pagina"
},
"bProcessing": true,
"bServerSide": true,
"iDisplayLength": 25,
"iDisplayStart": 0,
"sAjaxSource": "/tool/pdi/list/grid/todo",
"aoColumns" : [{"mData":"id","sTitle":"id","bVisible":false},{"mData":"endDate","sTitle":"Einddatum","type":"date-range"},{"mData":"dealerId","sTitle":"Dealer","sType":"numeric"},{"mData":"mechanicId","sTitle":"mechanicId","sType":"numeric","bVisible":false},{"mData":"mantisId","sTitle":"mantisId","sType":"numeric","bVisible":false},{"mData":"mantisStatus","sTitle":"mantisStatus","bVisible":false},{"mData":"mantisSubject","sTitle":"Mantisonderwerp","sClass":"mantis"},{"mData":"mantisSummary","sTitle":"mantisSummary","bVisible":false},{"mData":"komNo","sTitle":"Komnr"},{"mData":"gidsOrderId","sTitle":"GIDS-WOnr","sType":"numeric","sClass":"edit"},{"mData":"brand","sTitle":"brand","bVisible":false},{"mData":"model","sTitle":"model","bVisible":false},{"mData":"chassisNum","sTitle":"chassisNum","bVisible":false},{"mData":"shortChassisNum","sTitle":"shortChassisNum","bVisible":false},{"mData":"typeNum","sTitle":"typeNum","bVisible":false},{"mData":"color","sTitle":"color","bVisible":false},{"mData":"mechanicRemarks","sTitle":"Werkzaamheden","sClass":"edit"},{"mData":"timeUnits","sTitle":"TE","sClass":"edit"},{"mData":"conditionCode","sTitle":"conditionCode","bVisible":false},{"mData":"qtyAllocated","sTitle":"qtyAllocated","bVisible":false},{"mData":"location","sTitle":"Lokatie"},{"mData":"workgroup","sTitle":"workgroup","bVisible":false},{"mData":"hasI4Order","sTitle":"hasI4Order","bVisible":false},{"mData":"hasExactOrder","sTitle":"Exact","type":"twitter-dropdown","values":[0,1]},{"mData":"hasPartsInStock","sTitle":"Onderdelen","type":"twitter-dropdown","values":[0,1]},{"mData":"hasGo","sTitle":"GNG","sType":"numeric","type":"twitter-dropdown","values":[0,1]},{"mData":"hasPdi","sTitle":"hasPdi","bVisible":false},{"mData":"hasFuelJob","sTitle":"hasFuelJob","bVisible":false},{"mData":"hasWashProgram","sTitle":"hasWashProgram","bVisible":false},{"mData":"washProgram","sTitle":"washProgram","bVisible":false},{"mData":"undockDate","sTitle":"undockDate","bVisible":false},{"mData":"partsReceivedDate","sTitle":"partsReceivedDate","bVisible":false},{"mData":"goDate","sTitle":"goDate","bVisible":false},{"mData":"exactOrderDate","sTitle":"exactOrderDate","bVisible":false},{"mData":"created","sTitle":"created","bVisible":false},{"mData":"fueljobInvoiced","sTitle":"fueljobInvoiced","type":"twitter-dropdown","values":[0,1],"bVisible":false},{"mData":"fueljobInvoicedDate","sTitle":"fueljobInvoicedDate","bVisible":false},{"mData":"isDeleted","sTitle":"isDeleted","bVisible":false},{"mData":"mechanicName","sTitle":"monteur","sDefaultContent":"<\/i> selecteer monteur","sClass":"selectMechanic","bVisible":false}],
"aaSorting": [],
"bStateSave": true,
"fnStateSave": function(oSettings, oData) {
localStorage.setItem("Datatables_todo", JSON.stringify(oData));
},
"fnStateLoad": function(oSettings) {
return JSON.parse(localStorage.getItem("Datatables_todo"));
},
"bScrollCollapse": true,
//"sScrollX": "100%",
//"sScrollXInner": "200%",
"fnDrawCallback": function (o) {
/* Position the ColVis button as needed */
var nColVis = $('div.ColVis button', o.nTableWrapper)[0];
$(nColVis).addClass('btn btn-info');
$(nColVis).css('margin-bottom', '20px');
var nColVisLabel = $('div.ColVis button span', o.nTableWrapper)[0];
$(nColVisLabel).html('');
if ($('td.editingrid').length > 0) {
$('td.editingrid', this.fnGetNodes()).editable('', {
"callback": function(sValue, y) {
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue, aPos[1]);
},
"submitdata": function(value, settings) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition(this)[2]
};
},
"height": "34px",
"width": "100%"
});
}
if (typeof bindGridCheckboxEvents !== "undefined") {
bindGridCheckboxEvents();
}
},
"fnRowCallback": function(nRow, aData) {
$(nRow).attr("id", aData.id);
},
"fnInitComplete": function(oSettings, json) {
if (typeof bindGridCheckboxEvents !== "undefined") {
bindGridCheckboxEvents();
}
var reloadButton = $('');
$("div.ColVis").append(reloadButton);
$(reloadButton).click(function() {
oTable.fnReloadAjax();
});
}
,
"oColReorder": {
"aiOrder": [8,9,2,23,24,25,17,20,16,6,1,18,12,11,38,21,15,0,14,13,3,5,19,4,7,22,26,27,28,29,30,31,32,33,34,35,36,37,10]
}
});
[/code]
I really hope someone can help me!
Thanks a million!
Martin
First of all, kudo's for Datatables, imho the best grid there is!
When i enable the colreorder plugin it does reorder the columns perfectly, except when sorting it returns the original index.
I tried the stable and the nightly from this site and the latest from github. Also tried other variants like colreorder with resize. The all do the initial reordering just fine, but on sort it always gives the original column index.
I'm using datatables 1.9.4 and colReorder 1.0.8 - 1.1.0-dev both give the same problem.
[code]
var oTable;
oTable = $("#todo").dataTable({
"sDom": "RC<'row'<'span6'l>f<'span6'>r>t<'row'<'span6'i><'span6'p>>",
"oLanguage": {
"sLengthMenu": "_MENU_ records per pagina"
},
"bProcessing": true,
"bServerSide": true,
"iDisplayLength": 25,
"iDisplayStart": 0,
"sAjaxSource": "/tool/pdi/list/grid/todo",
"aoColumns" : [{"mData":"id","sTitle":"id","bVisible":false},{"mData":"endDate","sTitle":"Einddatum","type":"date-range"},{"mData":"dealerId","sTitle":"Dealer","sType":"numeric"},{"mData":"mechanicId","sTitle":"mechanicId","sType":"numeric","bVisible":false},{"mData":"mantisId","sTitle":"mantisId","sType":"numeric","bVisible":false},{"mData":"mantisStatus","sTitle":"mantisStatus","bVisible":false},{"mData":"mantisSubject","sTitle":"Mantisonderwerp","sClass":"mantis"},{"mData":"mantisSummary","sTitle":"mantisSummary","bVisible":false},{"mData":"komNo","sTitle":"Komnr"},{"mData":"gidsOrderId","sTitle":"GIDS-WOnr","sType":"numeric","sClass":"edit"},{"mData":"brand","sTitle":"brand","bVisible":false},{"mData":"model","sTitle":"model","bVisible":false},{"mData":"chassisNum","sTitle":"chassisNum","bVisible":false},{"mData":"shortChassisNum","sTitle":"shortChassisNum","bVisible":false},{"mData":"typeNum","sTitle":"typeNum","bVisible":false},{"mData":"color","sTitle":"color","bVisible":false},{"mData":"mechanicRemarks","sTitle":"Werkzaamheden","sClass":"edit"},{"mData":"timeUnits","sTitle":"TE","sClass":"edit"},{"mData":"conditionCode","sTitle":"conditionCode","bVisible":false},{"mData":"qtyAllocated","sTitle":"qtyAllocated","bVisible":false},{"mData":"location","sTitle":"Lokatie"},{"mData":"workgroup","sTitle":"workgroup","bVisible":false},{"mData":"hasI4Order","sTitle":"hasI4Order","bVisible":false},{"mData":"hasExactOrder","sTitle":"Exact","type":"twitter-dropdown","values":[0,1]},{"mData":"hasPartsInStock","sTitle":"Onderdelen","type":"twitter-dropdown","values":[0,1]},{"mData":"hasGo","sTitle":"GNG","sType":"numeric","type":"twitter-dropdown","values":[0,1]},{"mData":"hasPdi","sTitle":"hasPdi","bVisible":false},{"mData":"hasFuelJob","sTitle":"hasFuelJob","bVisible":false},{"mData":"hasWashProgram","sTitle":"hasWashProgram","bVisible":false},{"mData":"washProgram","sTitle":"washProgram","bVisible":false},{"mData":"undockDate","sTitle":"undockDate","bVisible":false},{"mData":"partsReceivedDate","sTitle":"partsReceivedDate","bVisible":false},{"mData":"goDate","sTitle":"goDate","bVisible":false},{"mData":"exactOrderDate","sTitle":"exactOrderDate","bVisible":false},{"mData":"created","sTitle":"created","bVisible":false},{"mData":"fueljobInvoiced","sTitle":"fueljobInvoiced","type":"twitter-dropdown","values":[0,1],"bVisible":false},{"mData":"fueljobInvoicedDate","sTitle":"fueljobInvoicedDate","bVisible":false},{"mData":"isDeleted","sTitle":"isDeleted","bVisible":false},{"mData":"mechanicName","sTitle":"monteur","sDefaultContent":"<\/i> selecteer monteur","sClass":"selectMechanic","bVisible":false}],
"aaSorting": [],
"bStateSave": true,
"fnStateSave": function(oSettings, oData) {
localStorage.setItem("Datatables_todo", JSON.stringify(oData));
},
"fnStateLoad": function(oSettings) {
return JSON.parse(localStorage.getItem("Datatables_todo"));
},
"bScrollCollapse": true,
//"sScrollX": "100%",
//"sScrollXInner": "200%",
"fnDrawCallback": function (o) {
/* Position the ColVis button as needed */
var nColVis = $('div.ColVis button', o.nTableWrapper)[0];
$(nColVis).addClass('btn btn-info');
$(nColVis).css('margin-bottom', '20px');
var nColVisLabel = $('div.ColVis button span', o.nTableWrapper)[0];
$(nColVisLabel).html('');
if ($('td.editingrid').length > 0) {
$('td.editingrid', this.fnGetNodes()).editable('', {
"callback": function(sValue, y) {
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue, aPos[1]);
},
"submitdata": function(value, settings) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition(this)[2]
};
},
"height": "34px",
"width": "100%"
});
}
if (typeof bindGridCheckboxEvents !== "undefined") {
bindGridCheckboxEvents();
}
},
"fnRowCallback": function(nRow, aData) {
$(nRow).attr("id", aData.id);
},
"fnInitComplete": function(oSettings, json) {
if (typeof bindGridCheckboxEvents !== "undefined") {
bindGridCheckboxEvents();
}
var reloadButton = $('');
$("div.ColVis").append(reloadButton);
$(reloadButton).click(function() {
oTable.fnReloadAjax();
});
}
,
"oColReorder": {
"aiOrder": [8,9,2,23,24,25,17,20,16,6,1,18,12,11,38,21,15,0,14,13,3,5,19,4,7,22,26,27,28,29,30,31,32,33,34,35,36,37,10]
}
});
[/code]
I really hope someone can help me!
Thanks a million!
Martin
This discussion has been closed.
Replies
$sColumnName = $this->getRequest()->getParam('mDataProp_' . $this->getRequest()->getParam('iSortCol_' . $i, ''));