How to hide a button

How to hide a button

INTONEINTONE Posts: 153Questions: 58Answers: 6
edited July 2014 in TableTools

I have read in the docs that I can call a fnInit on a tabletools button but I don't know how to show/hide button as needed. Here is my code:

aButtons: [
        { sExtends: "editor_create" ,
            editor: editor          ,
             "fnInit": function ( nButton, oConfig ) {
            //check if this user has the right to see/use the button to create new record
                        if(S(session({"id":1}).select("write_user_roles")).toString() == "No"){
                        //some code to hide the button
                    } else {
                       //some code to show the button

        { sExtends: "editor_edit"   ,editor: editor },
        { sExtends: "editor_remove" ,editor: editor },
        { sExtends: "select_none"   ,editor: editor }

This question has an accepted answers - jump to answer


  • allanallan Posts: 56,819Questions: 1Answers: 9,029 Site admin
    Answer ✓

    There isn't currently an API to show / hide a button in TableTools. It can be done by setting the DOM visibility of the button, but I would suggest that you simply don't add the create button tot he array if the user doesn't have access.

    buttons = [ ... ];
    if ( userHasCreateAccess ) {
      buttons.unshift( { ... create button } );


This discussion has been closed.