Save Column order when using ColVis aiExclude
Save Column order when using ColVis aiExclude
I'm using ColReorder and ColVis and they both work fine individually.
I can reorder columns and the order saves so the user see the same column order next time. However when I try to use aiExclude in ColVis I can still reorder columns but I lose the ability for this to be saved.
Any Idea's?
[code]
$(document).ready(function() {
$('#example').dataTable({
"sDom": 'CRT<"clear"><"H"lfr>t<"F"ip>C', //T =TableTools. C=ColVis R=ColReorder
"sPaginationType": "full_numbers",
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bProcessing": true,
"bInfo": true,
"bAutoWidth": true,
"bStateSave": true,
"bRetrieve": true,
"bJQueryUI": true,
// "oColVis":
// {
// // "buttonText": "Change columns",
// // "activate": "mouseover",
// "aiExclude": [14, 16, 18, 20, 22, 24]
// },
"aoColumnDefs":
[
{ "bVisible": false, "aTargets": [0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] },
{ "bSearchable": false, "aTargets": [0, 5, 14, 16, 18, 20, 22, 24] },
{ "asSorting": ["desc", "asc"], "aTargets": [1] },
{"iDataSort": 13, "aTargets": [14] },
{"iDataSort": 15, "aTargets": [16] },
{"iDataSort": 17, "aTargets": [18] },
{"iDataSort": 19, "aTargets": [20] },
{"iDataSort": 21, "aTargets": [22] },
{"iDataSort": 23, "aTargets": [24] }
],
"oTableTools": {
"sSwfPath": "../jquery/DataTables-1.7.5/extras/TableTools/media/swf/copy_cvs_xls_pdf.swf",
"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": ["csv", "xls", "pdf"]
}
]
}
});
$('#reset').click(function() {
ColReorder.fnReset(oTable);
return false;
});
});
[/code]
I can reorder columns and the order saves so the user see the same column order next time. However when I try to use aiExclude in ColVis I can still reorder columns but I lose the ability for this to be saved.
Any Idea's?
[code]
$(document).ready(function() {
$('#example').dataTable({
"sDom": 'CRT<"clear"><"H"lfr>t<"F"ip>C', //T =TableTools. C=ColVis R=ColReorder
"sPaginationType": "full_numbers",
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bProcessing": true,
"bInfo": true,
"bAutoWidth": true,
"bStateSave": true,
"bRetrieve": true,
"bJQueryUI": true,
// "oColVis":
// {
// // "buttonText": "Change columns",
// // "activate": "mouseover",
// "aiExclude": [14, 16, 18, 20, 22, 24]
// },
"aoColumnDefs":
[
{ "bVisible": false, "aTargets": [0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] },
{ "bSearchable": false, "aTargets": [0, 5, 14, 16, 18, 20, 22, 24] },
{ "asSorting": ["desc", "asc"], "aTargets": [1] },
{"iDataSort": 13, "aTargets": [14] },
{"iDataSort": 15, "aTargets": [16] },
{"iDataSort": 17, "aTargets": [18] },
{"iDataSort": 19, "aTargets": [20] },
{"iDataSort": 21, "aTargets": [22] },
{"iDataSort": 23, "aTargets": [24] }
],
"oTableTools": {
"sSwfPath": "../jquery/DataTables-1.7.5/extras/TableTools/media/swf/copy_cvs_xls_pdf.swf",
"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": ["csv", "xls", "pdf"]
}
]
}
});
$('#reset').click(function() {
ColReorder.fnReset(oTable);
return false;
});
});
[/code]
This discussion has been closed.
Replies
[code]
(typeof this.s.dt.aoColumns[i]._ColReorder_iOrigCol != 'undefined' ? this.s.dt.aoColumns[i]._ColReorder_iOrigCol : i)
[/code]
so that you end up with the below
[code]
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i
[code]
(typeof that.s.dt.aoColumns[i]._ColReorder_iOrigCol != 'undefined' ? that.s.dt.aoColumns[i]._ColReorder_iOrigCol : i)
[/code]
so that you end up with the below
[code]
$(nButton).click( function (e) {
for ( var i=0, iLen=that.s.abOriginal.length ; i