Disable/Enable New/Delete buttons based on user permissions/interaction

Disable/Enable New/Delete buttons based on user permissions/interaction

agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
edited April 2013 in Editor
Hello,
I'd like to enable/disable the Editor's New/Delete buttons based on user interaction and permissions (e.g.: if user has certain access level he can add or delete records from DataTable)

Is there any example out there?

Regards

Replies

  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    I don't have an example to hand of this, but if you look at how TableTools does the standard buttons, it uses the fnSelect method and simply adds or removes a class:

    [code]
    "fnSelect": function( nButton, oConfig ) {
    if ( this.fnGetSelected().length !== 0 ) {
    $(nButton).removeClass( this.classes.buttons.disabled );
    } else {
    $(nButton).addClass( this.classes.buttons.disabled );
    }
    },
    [/code]

    You could do something similar.

    However, I think TableTools should provide enable and disable methods for button control. I will look at adding this - hopefully today, but its already shaping p to be a busy day! I'll post back when it is committed.

    Allan
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Hi Allan,
    Were you able to look into this? Do you think it's something that can be added in future releases?
    Regards
  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    Doh - I must admit when I didn't manage to do it that day, it then promptly slipped my mind (although it was bookmarked to it would have happened eventually!).

    Thinking about it, TableTools doesn't actually have any way of addressing buttons which are on the page (they don't have a "name" for example), so actually this might not be quite as trivial as I had thought. However, I think this is an important ability to have, and it will certainly be going into v3 of TableTools, if I can't figure out a way of shoe horning it into the current v2 series.

    Allan
This discussion has been closed.