Excel output modify default behaviour

Excel output modify default behaviour

lordterrinlordterrin Posts: 22Questions: 10Answers: 1

Hi Folks,

It seems that with the excel export button, I can either include an action function, or not, but if I include one, it overrides the default action and no longer exports.

I'd like to pass the user through a function PRIOR to exporting to see if they have the correct level of access before they're allowed to download an Excel file.

Answers

  • Tom (DataTables)Tom (DataTables) Posts: 139Questions: 0Answers: 26
    edited June 2016

    I would suggest having a function that checks the user level on page load and then either adds or removes the button. This is so that the end user can't produce an error.

    You can use button().add() and buttons().remove() to perform these actions.

    You could override the the action function but doing this would override the default action, so I would recommend doing what is suggested above. (You could technically call the original method but it would be better to not let the user enter an error state at all).

    Thanks

    Tom

  • lordterrinlordterrin Posts: 22Questions: 10Answers: 1
    edited June 2016

    My hope was that the user could see the button - but be given a message that they don't have the right level of access, so they know the ability to export EXISTS, they just can't do it. Of course, using the buttons.add I could always write two buttons, one with a custom action and the other without, so that works too. Thanks!

    Update: The buttons.add code you have up there needs to be changed to button.add (without the s) :smile:

    Update 2: The button.add page is great to teach me the syntax of literally adding a button, but I'm still not sure on the exact text to add inside the function to get it to add an Excel download button. Have you seen any page on here that details that?

This discussion has been closed.