• Resolved 20fudge21

    (@20fudge21)


    Hello,

    Is there any way you can preset the column visibility please? For example, the webpage only loads Columns 1-6 but the user can view the others if they wish using the column visibility button?

    Thanks so much for your help 🙂
    b.

    ps. have donated for the premium extensions that really work well!

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Yes, this is possible. Please add this to the “Custom Commands” text field on the table’s “Edit” screen:

    "columnDefs": [ { "visible": false, "targets": [ 6, 7, 8 ] } ]
    

    This will hide columns 7, 8, and 9 (counting starts with 0 in this type of code), but they can be made visible again using the Column Visibility button.

    Regards,
    Tobias

    Thread Starter 20fudge21

    (@20fudge21)

    hmmm…I tried this code and it doesn’t seem to have worked? Am I missing something obvious?

    Also, now the extension styling has disappeared from the page.

    Here is my shortcode that doesn’t seem to be working (and was before I tried to edit the custom commands). I have updated the plugins to the latest versions just now:

    [table id=1 responsive=”scroll” datatables_buttons=”colvis,copy,csv,excel,pdf,print” datatables_fixedcolumns_left_columns=2 /]

    Thanks in advance for your help,
    b.

    • This reply was modified 5 years, 2 months ago by 20fudge21.
    Thread Starter 20fudge21

    (@20fudge21)

    ps I’ve significantly shortened the table so that I could work with the custom Commands otherwise it was taking forever to open in wordpress (1700+ rows!)

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    where exactly did you add the code? And it seems that the “Use DataTables” checkbox might not be checked anymore, on the table’s “Edit” screen?

    Regards,
    Tobias

    Thread Starter 20fudge21

    (@20fudge21)

    Ahhh yes, sorry I must have unclicked it by mistake – doh! All the extensions have appeared but the datatable buttons are no longer white but seem to be transparent?

    Re: column visibility – I put in your code in the ‘Features of the datatable javascript library’ section in the text box that’s labelled ‘custom commands’ – is that correct?

    Thank you 🙂

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    nice, it’s working again! Yes, you put that code in the correct place.

    The changed colors are a result of the updated version that I shipped today. To restore the colors, please add this to the “Custom CSS” textarea on the “Plugin Options” screen of TablePress:

    button.dt-button {
        background: linear-gradient(to bottom, white 0%, #e9e9e9 100%);
    }

    One more thing, to rule out interference with the FixedColumns feature: Please remove the responsive="scroll" parameter from the Shortcode.

    Regards,
    Tobias

    Thread Starter 20fudge21

    (@20fudge21)

    Awesome – it works!

    Thanks so much Tobias, really appreciated!

    All best,
    b

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Pre set column visibility’ is closed to new replies.