Setting the buttons when used as a RadGrid CommandItem

7 posts, 1 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 27 May 2009 Link to this post

    I've a grid in a UserControl. The CommandItem template is defined like this ...
            <CommandItemTemplate> 
            <telerik:RadToolBar runat="server" ID="GridCommandItemToolbar" AutoPostBack="false" Skin="WebBlue" 
                OnClientButtonClicked="ToolBarButtonClicked" Style="width: 100%" Visible="true"
                <CollapseAnimation Duration="200" Type="OutQuint" /> 
                <Items> 
                    <telerik:RadToolBarButton runat="server" Enabled="false" ToolTip="Add Document" Value="AddDocument" ImageUrl="~/Images/Office/document_file/png/16/document_add_16x16.png"
                    </telerik:RadToolBarButton> 
                    <telerik:RadToolBarButton runat="server" Enabled="false" ToolTip="Edit Document" Value="EditDocument" ImageUrl="~/Images/Office/document_file/png/16/document_edit_16x16.png"
                    </telerik:RadToolBarButton> 
                    <telerik:RadToolBarButton runat="server" Enabled="false" ToolTip="Delete Document" Value="DeleteDocument" ImageUrl="~/Images/Office/document_file/png/16/document_delete_16x16.png"
                    </telerik:RadToolBarButton> 
                    <telerik:RadToolBarButton runat="server" IsSeparator="true"></telerik:RadToolBarButton> 
                    <telerik:RadToolBarButton runat="server" Enabled="false" ToolTip="View Document History" Value="ViewHistory" CheckOnClick="true" Checked="false" AllowSelfUnCheck="true" ImageUrl="~/Images/Office/document_file/png/16/document_properties_16x16.png"
                    </telerik:RadToolBarButton> 
     
                </Items> 
            </telerik:RadToolBar> 
            </CommandItemTemplate> 

    I need to be able to enble/disable the buttons based on values and events on the calling page.

    I thought to do it like this ...
    var tb = $find("<%= GridCommandItemToolbar.ClientID %>"); 
    But "GridCommandItemToolbar" isn't recognised, which I suppose is OK. But I can't seem to create a property on the UserControl that lets me get at the ToolBar server-side so I can access its ClientID in the <% %> code block on the page.

    Can anyone offer a solution?

    --
    Stuart






  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 27 May 2009 Link to this post

    Never mind chaps, I've sorted it.

    For the curious amongst you, the answer appears to be to:
    1. Create a global variable on your calling page,
    2. Wire up the OnClientLoad toolbar client-side event,
    3. In the event handler access the object in the previously declared gloabl variable.

    Clever me! 8-)

    --
    Stuart
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 27 May 2009 Link to this post

    Well, I'd sorted it for accessing the ToolBar on the client, but now I need access to the ToolBar server-side.

    Hints anyone?

    --
    Stuart
  5. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 27 May 2009 Link to this post

    I could get at using...
    RadToolBar tb = (RadToolBar)RadGrid1.MasterTableView.Controls[0].Controls[0].Controls[0].Controls[0].Controls[1]; 
    but that can't be the right/best way, can it?

    --
    Stuart

  6. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 28 May 2009 Link to this post

    Does anyone want to take a shot at this?

    --
    Stuart
  7. Answer
    Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 28 May 2009 Link to this post

    Hi Stuart,

    You can try finding the ToolBar server side as shown below:

    GridCommandItem commandItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem;  
    RadToolBar toolBar = commandItem.FindControl("GridCommandItemToolbar"as RadToolBar; 

    More information on how to access controls in RadGrid is available here.

    Kind regards,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 28 May 2009 Link to this post

    Iana,

    Thanks for that. I would never have found that without reading all of the help file!

    Thanks again!

    --
    Stuart
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017