Colvis does not work initially

Colvis does not work initially

jamessteelforthjamessteelforth Posts: 17Questions: 4Answers: 0
edited October 2014 in Free community support

My initialization:

        $('#example').dataTable({
         "columnDefs":
         {"orderable": false, "targets": "_all" },
     { "width": "60px",  "targets": [2,3]},
     { "width": "180px", "targets": [30,34,35,36,37,38,39]},
     { "width": "250px", "targets": [4,5]},
     { "width": "100px", "targets:[1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,32,33,40,41,42,43,44,45,46,47]},
         { "visible": false, "targets":[5,6,7,8,9,10,11,12,13,14,15,22,23,24,25,26,27]} 

                      ],
        "AutoWidth": false,
        "processing":true,
        "scrollX": true,
        "bStateSave": true,
        "bRetrieve": true,
        "scrollY": "430px",
        "scrollCollapse": true,
        "paginate": false,
        "dom": "C<'clear'>lrtp",
        "colVis": {
                    "exclude": [0,1],
                    "showAll": "Show all",
                    "showNone": "Show none",
                    "align":"left"
                  },
        "columns": 
        [   
            { "title": "Row ID", "visible" : false },
            { "title": "<button onclick = 'DeleteButtonClick()'>Delete</button>"},
            { "title": "Effective Date", "visible" : false},
            { "title": "Item Number" },
            { "title": "Item Description" },
            { "title": "Price List Category" },
            { "title": "Price List Category Year" },
            { "title": "Edition Year"},
            { "title": "Acronym" },
            { "title": "Class" },
            { "title": "Secondary Category" },
            { "title": "Item Status"},
            { "title": "Price List Item Status" },
            { "title": "No Discount Allowed"},
            { "title": "Current List Price"},
            { "title": "Current Target Price"},
            { "title": "Current Specified Price"},
            { "title": "+/- % Specified price of target price"},
            { "title": "2 Previous Ed/2 Yrs Ago Qty"},
            { "title": "2 Previous Ed/2 Yrs Ago Sales"},
            { "title": "Previous Ed/PY Qty"},
            { "title": "Previous Ed/PY Sales"},
            { "title": "Previous Ed/PY Avg Sale Price"},
            { "title": "PY Specified Price"},
            { "title": "Previous Ed/PY Avg Sale Price vs PY SP $ Variance"},
            { "title": "Previous Ed/PY Avg Discount %"},
            { "title": "PY Specified Price Discount %"},
            { "title": "Previous Ed/PY Avg vs PY SP Discount % Variance"},
            { "title": "Curr Ed/CY Qty"},
            { "title": "Curr Ed/CY Sales"},
            { "title": "Projected Qty"},
            { "title": "Current List Price"},
            { "title": "Current Target Price"},
            { "title": "Current Target Price Discount %"},
            { "title": "Projected Specified Price"},
            { "title": "Projected Discount %"},
            { "title": "Apply discount on category level"},
            { "title": "Total Sales Based on Current Target Price"},
            { "title": "Total Sales Based on Projected Specified Price"},
            { "title": "Projected SP % of Target"},
            { "title": "Below FP Requires Finance Approval"},
            { "title": "Current Floor Price"},
            { "title": "Actuals Qty"},
            { "title": "Actuals Sales"},
            { "title": "Actuals Avg Sale Price"},
            { "title": "Actuals Avg Sale Price vs Projected SP $ Variance"},
            { "title": "Actuals Avg Discount %"},
            { "title": "Actuals Avg vs Projected SP Discount % Variance"}
        ]           
    });

So i have kept a few columns hidden by default. But when i try to individually show one or two columns, using Show / Hide button, It doesn't work i.e. column visibility toggle doesn't work.

I have to click on "Show All", make all column visible once, and then try to show or hide individual columns using Show / Hide button, then it works.

I need to get Show / Hide button to work even with default visibility.

Answers

  • allanallan Posts: 63,386Questions: 1Answers: 10,449 Site admin

    "bStateSave": true,

    The previous state is being restored. Might that be the issue?

    Failing that, can you link to the page so I can take a look please?

    Allan

This discussion has been closed.