Get all buttons client-side

5 posts, 1 answers
  1. JP
    JP avatar
    120 posts
    Member since:
    Aug 2011

    Posted 05 Dec 2011 Link to this post

    Hi,

    I need to get buttons by their attributes (these attributes are set server-side). These buttons need to be activated, all other buttons must be deactivated. With activated I mean "visible", not "enabled".

    How I can I get a collection of all buttons attached to the RibbonBar and how can I get their attributes?

    Thanks!
  2. Answer
    Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 06 Dec 2011 Link to this post

    Hello Jp,

    Unfortunately we have not implemented custom attributes for the RadRibbonBar yet. Instead you could use the Value property. And also there currently isn't a way to set the visibility on the client, so the only way is to set the Enabled property.
    Here's a sample code for the suggested approach:

    function ClientLoad(sender){
        var ribbon = $find("RadRibbonBar1");
        for (var i = 0; i < ribbon.get_tabs().get_count(); i++) {
            var tab =  ribbon.get_tabs().getTab(i);
            for (var j = 0; j < tab.get_groups().get_count(); j++) {
                var group = tab.get_groups().getGroup(j)
                for (var k = 0; k < group.get_items().get_count(); k++) {
                    var item = group.get_items().getItem(k);
                    if (item.get_value && item.get_value() == "enabledValue"){
                        item.set_enabled(false);
                    }
                }
            }
        }
    }
    Best wishes,
    Bozhidar
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Peter From LA
    Peter From LA avatar
    35 posts
    Member since:
    May 2005

    Posted 16 Jan 2012 Link to this post

    I found a way to totally hide the buttons:
    function MakeButtonVisible(buttonValue, isVisible)
    {
         var button = RIBBON_BAR.findButtonByValue(buttonValue);
         if (button)
         {
              button.get_element().style.display = isVisible ? "" : "none";
         }
    }

    That being said, I encounter other issues. For example the width of the Group remains the same as though all buttons are visible - funny thing is it works fine in compatibility mode in IE.
    Also if you have a very wide group (with many large buttons) which fits fine in the screen and you switch tabs, when you get to the tab with the wide group all buttons are converted to small buttons.
    I am not sure all those issues are related, but they are annoying...


  5. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 17 Jan 2012 Link to this post

    Hello Peter,

    About your first question - when you alter the visibility of the buttons in this way, you do it without the knowing of the RibbonBar. As far as it's concerned, the items it send to the browser are still visible. That's why the calculations of the GroupWidth are incorrect.

    This, as well as the second issue you've described, are related to the RibbonBar's resizing, on which we are currently working. The new resizing should be available in our next Quarter release. It should fix a lot of issues that we currently have, as well as the ones mentioned here.
     
    Regards,
    Bozhidar
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  6. Peter From LA
    Peter From LA avatar
    35 posts
    Member since:
    May 2005

    Posted 17 Jan 2012 Link to this post

    Fabtastic... I cant wait for the new release...  :)
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017