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

RadToolBar button visibility inside Grid/Mastertable/Toolbar

3 Answers 323 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Divya
Top achievements
Rank 1
Divya asked on 16 May 2016, 03:01 AM

I have following code structute

 

<telerik:RadGrid    ID="xx">
    <MasterTableView CommandItemDisplay="Top" DataKeyNames="Key">
        <RowIndicatorColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <CommandItemTemplate>
            <telerik:RadToolBar ID="yy" runat="server" AutoPostBack="true" Width="100%">
                <Items>
                    <telerik:RadToolBarButton  CommandName="InitInsert" ResourceName="Add" ImageUrl="~/App_Themes/Default/Add.gif" Text="Add" ></telerik:RadToolBarButton>
                </Items>
            </telerik:RadToolBar> ....................Cont....

 

How can I hide RadToolBarButton  using C# code ? how can I access this toolbar button if its inside Grid/MasterTable/Toolbar hirarchi

 

3 Answers, 1 is accepted

Sort by
0
Divya
Top achievements
Rank 1
answered on 16 May 2016, 04:00 PM
Can anybody help me on this ?
0
Divya
Top achievements
Rank 1
answered on 16 May 2016, 04:07 PM

I want to do this In a Private method ...

public void LoadData()
        {
          .............................................
            if (Data.Count == 1)
            {
                AddFlag = false;

I can access following but not inner items
 RadGrid grid = (RadGrid )this.FindControl("xx"); 

 tried this but no luck
                //Radtoolbar = (Radtoolbar )this.FindControl("yy");
               // ((RadtoolbarButton)toolbar.FindButtonByCommandName("InitInsert")).Visible = false;


            }
        }

 

0
Ivan Danchev
Telerik team
answered on 18 May 2016, 02:22 PM
Hello Divya,

An approach you can use to set the ToolBar to visible or invisible is to set its CssClass property. So when you want to make it invisible you can set the following custom class:
toolbar.CssClass = "toolBarInvisible";

and when you want to make it visible again the following one:
toolbar.CssClass = "toolBarVisible";

You will have to add the corresponding CSS rules which will set the visibility depending on the ToolBar's currently set custom class:
.toolBarInvisible {
    visibility: hidden;
}
 
.toolBarVisible{
    visibility: visible;
}

For accessing the ToolBar you can see this forum thread, where it is shown how to access a control placed in a Grid's CommandItemTemplate.

Regards,
Ivan Danchev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
ToolBar
Asked by
Divya
Top achievements
Rank 1
Answers by
Divya
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or