Save Column order when using ColVis aiExclude

Save Column order when using ColVis aiExclude

danw82danw82 Posts: 6Questions: 0Answers: 0
edited February 2011 in Plug-ins
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]

Replies

  • FloppyKingFloppyKing Posts: 5Questions: 0Answers: 0
    in ColVis.js try replacing the "i" in the indexOf statement on line 419 with

    [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
  • FloppyKingFloppyKing Posts: 5Questions: 0Answers: 0
    edited November 2011
    I guess that appears to mess with the bRestore functionality as well, i'll have to look into adjusting the _fnDomRestoreButton function as well. I'll probably do that tomorrow as i need to get this to work correctly for a project of mine.
  • FloppyKingFloppyKing Posts: 5Questions: 0Answers: 0
    in ColVis.js try replacing the "i" in the that.s.abOriginal[i] statement on line 462 with

    [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
This discussion has been closed.