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

Why are template items inaccessible?

4 Answers 81 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 16 Aug 2011, 04:59 AM

I am trying to populate a rad combo box via a object data source, but I cannot seem to access it when I put it into a RadRibbonBar.

Am I missing something?   Here is what I have:

<telerik:RadRibbonBar runat="server">
    <telerik:RibbonBarTab Text="Home">
        <telerik:RibbonBarGroup Text="Selections" >
            <Items>
                <telerik:RibbonBarTemplateItem>
                    <telerik:RadComboBox ID="versionList" Label="Version" runat="server" 
                        DataTextField="Version.Name" DataValueField="Version.ID" >
                    </telerik:RadComboBox>
                </telerik:RibbonBarTemplateItem>
            </Items>
        </telerik:RibbonBarGroup>
    </telerik:RibbonBarTab>
</telerik:RadRibbonBar>

In my code, versionList is not recognized as an object and I cannot bind to it.   As shown below.   "versionList" is not defined.

versionList.DataSource = version.Items;

What am I doing wrong?


4 Answers, 1 is accepted

Sort by
0
Accepted
Kate
Telerik team
answered on 16 Aug 2011, 12:28 PM
Hi Steven,

Here is how you can access a RadComboBox control when it is inside a RadRibbonBarTemplate:

markup:
<telerik:RadRibbonBar ID="RadRibbonBar1" runat="server" SelectedTabIndex="0">
            <telerik:RibbonBarTab Text="tab1">
                <telerik:RibbonBarGroup Text="Group1" EnableLauncher="false" Value="1">
                    <Items>
                    <telerik:RibbonBarButton Size="Medium" Text="New" />
                    <telerik:RibbonBarButton Size="Medium" Text="Edit"  />
                    </Items>
                </telerik:RibbonBarGroup>
            </telerik:RibbonBarTab>
            <telerik:RibbonBarTab Text="tab2" Value="tab2">
                <telerik:RibbonBarGroup Text="Font">
                    <Items>
                        <telerik:RibbonBarTemplateItem>
                            <Template>
                                <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="90px">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="Cambria" />
                                        <telerik:RadComboBoxItem Text="Calibri" Selected="true" />
                                        <telerik:RadComboBoxItem Text="Arial" />
                                        <telerik:RadComboBoxItem Text="Book Antiqua" />
                                    </Items>
                                </telerik:RadComboBox>
                            </Template>
                        </telerik:RibbonBarTemplateItem>
                    </Items>
                </telerik:RibbonBarGroup>
            </telerik:RibbonBarTab>
        </telerik:RadRibbonBar>

code behind:
protected void Page_Load(object sender, EventArgs e)
    {                      
        RibbonBarTab tab2 = RadRibbonBar1.FindTabByValue("tab2");
        RadComboBox combo1 = (RadComboBox)tab2.Groups[0].Items[0].FindControl("RadComboBox1");
    }

Regards,
Kate
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Steven
Top achievements
Rank 1
answered on 16 Aug 2011, 02:22 PM
Is this documented somewhere that I can read more about this?
0
Kate
Telerik team
answered on 17 Aug 2011, 01:34 PM
Hi Steven,

Since the RadRibbonBar is a new control, its documentation is still not very rich in terms of different scenarios. Therefore this is still not documented. However, I will make sure to include it as a new help article. Meanwhile here is some more explanation on the code above.

In order to find the control that is located in a Template of a RadRibbonBar, first you need to find the tab that it is located in. This is done by using the FindTabByValue property (note that to make this work, the tab needs to have a previously assigned value, ex:  <telerik:RibbonBarTab Text="tab2" Value="tab2"> )
Then you will need to find the Group by its index (this is zero in the particular case - Groups[0]) that is placed in the tab with Value="tab2" and get the Group's first item (again this is done by index - Items[0]). Further, by using the FindControl property you can access the RadComboBox control.  

I hope this is more clear. 

Best wishes,
Kate
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Steven
Top achievements
Rank 1
answered on 17 Aug 2011, 03:27 PM
Thank you for the information.  

I understand this is a new control, especially when dealing with the template items, which is part of the newest release, and with that the documentation tends to lag a little.  

What I was surprised about though, was that the object was not directly accessible, but that you had to go through a find function, especially when dealing with template items.

I hope that is something that will change in the future.

Thanks again for all your help.
Tags
RibbonBar
Asked by
Steven
Top achievements
Rank 1
Answers by
Kate
Telerik team
Steven
Top achievements
Rank 1
Share this question
or