This is a migrated thread and some comments may be shown as answers.

Get all buttons client-side

4 Answers 95 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
JP
Top achievements
Rank 1
JP asked on 05 Dec 2011, 02:20 PM
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!

4 Answers, 1 is accepted

Sort by
0
Accepted
Bozhidar
Telerik team
answered on 06 Dec 2011, 06:39 PM
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
0
Peter From LA
Top achievements
Rank 1
answered on 17 Jan 2012, 03:44 AM
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...


0
Bozhidar
Telerik team
answered on 17 Jan 2012, 05:44 PM
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
0
Peter From LA
Top achievements
Rank 1
answered on 17 Jan 2012, 05:46 PM
Fabtastic... I cant wait for the new release...  :)
Tags
RibbonBar
Asked by
JP
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Peter From LA
Top achievements
Rank 1
Share this question
or