• Resolved brimarbob

    (@brimarbob)


    We use tablepress for our choir website and specifically for members to access their music and rehearsal tracks. The table has a column for the song name, the score download, alto, soprano, baritone, demo and backing tracks. Each song takes one row.

    What I would like to do is have the user choose between alto, soprano, baritone, demo and backing and the table to be automatically filtered to just display the song title, score and the chosen column. Ideally the user should be able to make the selection at the top of the table and not the bottom.

    Is this possible with the current extensions?

    Thanks – Bob

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Yes! The TablePress DataTables Buttons Extension from https://tablepress.org/extensions/datatables-buttons/ should be a possibility here. It can add a Column Visibility button (“colvis”) that allows hiding undesired columns.

    Regards,
    Tobias

    Thread Starter brimarbob

    (@brimarbob)

    Thanks for that. I have just downloaded and installed the plugin extension and it is activated but I cannot get any buttons to appear even when I cut and paste the command line datatables_buttons=”colvis,copy,csv,excel,pdf,print and add it to the table shortcode. In fact I cant get any option to work.

    If I hide a column, will I be able to view it using the colvis settings menu?

    Thanks – Bob

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    can you please check if the “Use DataTables” checkbox is turned on, on the table’s “Edit” screen. This is mandatory for the buttons to work (the individual features like sorting, etc. can be turned off if they are not desired).

    If that does not help, can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!

    And yes, hiding columns and making them visible with colvis again is possible – if you use a special method for hiding them. In particular, you’d have to hide them by adding this to the “Custom Commands” text field on the table’s “Edit” screen:

    "columnDefs": [ { "visible": false, "targets": [ 2, 4, 5 ] } ]
    

    In this example, the 3rd, 5th, and 6th column would be hidden (counting the columns starts with 0 in this code).

    Regards,
    Tobias

    Thread Starter brimarbob

    (@brimarbob)

    Hi,

    Yes – the datatables is set to on in the table edit screen and the line you gave to add in that section works perfectly – thanks for that – so I can hide columns in prep for the button so users can select the ones they want. Still no button though.This is the code lines on the run up to calling the table:

    `<div style=”height: 150px; width: 95%; margin: 0px auto 0px; paddin2: 0px; background-image: url(‘https://www.singbentleyheath.org.uk/sbh/wp-content/uploads/Holly-Banner-150×150.png&#8217;);background-repeat: repeat-x;background-position: center;”> </div>’
    ‘<h3 style=”text-align: center;”>Christmas Music</h3>’
    ‘[table id=2 DataTables_Buttons=”colvis” /]’

    We are using the weaver extreme theme and this page hasn’t been converted to blocks yet. It was originally created with a 3d editor and I then recoded it. There are a number of tables called and they all load correctly but none show the buttons. As some of the music is copyright, I will make a new page with a sample table and send a link for that.

    One final question – can I stop columns appearing in the colvis box i,e, prevent users turning them on/off?

    Thanks – Bob

    • This reply was modified 3 years, 5 months ago by brimarbob.
    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    it seems like you are using mixed-case letters in the Shortcode, i.e. DataTables_Buttons instead of datatables_buttons. Please change that to all lowercase.

    And yes, you can define which columns should appear in the colvis box. For that, extend the used “Custom Command” to

    "columnDefs": [ { "visible": false, "targets": [ 2, 4, 5 ] } ], "buttons": [ { "extend": "colvis", "columns": [ 1, 3, 5] } ]
    

    That second list of column numbers (again, counting starts with 0) defines which columns should appear in the colvis box.

    Regards,
    Tobias

    Thread Starter brimarbob

    (@brimarbob)

    Well Tobias, I have tried so many variations on the spelling etc of the datatables_buttons option and I even tried putting it in the shortcode block on it’s own with no success.

    I have created a test page, cloned from the original with just the Christmas music. The link is
    https://www.singbentleyheath.org.uk/members-area/tablepress-test-page/

    The line calling the table currently reads:
    ‘[table id=2 datatables_buttons=”colvis” /]’
    and you can see that I have hidden all the columns related to the different choir parts using the code you supplied but there is no button to show a column ?? I’m sure it’s something simple/obvious but I can’t see it.

    Regards – Bob

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    one more try without quotation marks – to rule out that they are the “wrong” curly ones:

    [table id=2 datatables_buttons=colvis /]
    

    Regards,
    Tobias

    Thread Starter brimarbob

    (@brimarbob)

    I had tried that too but have done it again and updated the page. Checked I had the latest version of the extension and that it was still active as well.

    Regards – Bob

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    ah, now I see: It looks like that the “WP Google Maps” plugin that is also active on the site is interfering here. It’s also loading the DataTables files and by that it’s essentially overriding what TablePress has already loaded.
    Can you please try again after deactivating the “WP Google Maps” plugin?

    Regards,
    Tobias

    Thread Starter brimarbob

    (@brimarbob)

    OK – so that seems to work if I deactivate WP Google Maps – I can enable and disable columns from the box (BTW – it would be good to change the name of that button). Now we have the root cause, how do we fix it so I can have maps and tables?

    Regards – Bob

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi Bob,

    that’s a good question… From what I can see, there’s no map shown on this page. So, ideally, the WP Google Maps plugin should not load its copy of the JS library there (it would be useless), but should only load it on pages where the JS code is actually needed. That’s also the approach that TablePress takes.

    Regards,
    Tobias

    Thread Starter brimarbob

    (@brimarbob)

    Well we don’t need plugins that load unnecessarily. I have found a new Map Block which doesn’t conflict. Thanks for your help and if you could find a way to change the button text that would be ace. Cheque in the post!

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    that’s good to hear!

    Regarding the button text: For that, please modify the “Custom Command” that we created above. Please replace the part

    "buttons": [ { "extend": "colvis", "columns": [ 2, 3, 4, 5] } ]
    

    by

    "buttons": [ { "extend": "colvis", "text": "Select columns", "columns": [ 2, 3, 4, 5] } ]
    

    The string after "text" is what’s used as the button text.

    Regards,
    Tobias

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Is there an extension that allows users to select which columns to display from’ is closed to new replies.