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

Enable/Disable radtoolbar commanditems clientside

2 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
GlenB
Top achievements
Rank 1
GlenB asked on 22 May 2010, 02:58 AM
I am currently enabling and disabling my radtoolbar commanditems (for my radgrid) on the serverside with the following code. This is working fine but requires a postback to the server which is too slow (2 secs before buttons update).

Serverside code (VB):
    Protected Sub radGrid_Cases_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) 
        For Each cmdItem As GridCommandItem In radGrid_Cases.MasterTableView.GetItems(GridItemType.CommandItem) 
            Dim rdtlbr As RadToolBar = DirectCast(cmdItem.FindControl("rtb_Commands"), RadToolBar) 
            rdtlbr.FindItemByText("Edit Case").Enabled = True 
            rdtlbr.FindItemByText("Delete Case").Enabled = True 
            rdtlbr.FindItemByText("Print Case").Enabled = True 
            rdtlbr.FindItemByText("Email Case").Enabled = True 
            rdtlbr.FindItemByText("Edit Payments").Enabled = True 
        Next 
    End Sub 
 
    Public Sub DisableGridCommandButtons() 
        For Each cmdItem As GridCommandItem In radGrid_Cases.MasterTableView.GetItems(GridItemType.CommandItem) 
            Dim rdtlbr As RadToolBar = DirectCast(cmdItem.FindControl("rtb_Commands"), RadToolBar) 
            rdtlbr.FindItemByText("Edit Case").Enabled = False 
            rdtlbr.FindItemByText("Delete Case").Enabled = False 
            rdtlbr.FindItemByText("Print Case").Enabled = False 
            rdtlbr.FindItemByText("Email Case").Enabled = False 
            rdtlbr.FindItemByText("Edit Payments").Enabled = False 
        Next 
    End Sub 
 

I have been trying to change this over to be done on the client side (in the rowselected event) instead to make it more responsive, but I have been unable to find a clientside method of accessing these buttons as they are nested inside the radgrid commanditem toolbar.


2 Answers, 1 is accepted

Sort by
0
Accepted
Iana Tsolova
Telerik team
answered on 27 May 2010, 09:40 AM
Hi GlenB,

In order to achieve your goal, I would suggest you to handle the RadToolBar OnClientLoad client-side event. There you can get the client-side object of the RadToolBar and save it in a global variable. Then you can use this variable in the OnRowSelected client-side event of the grid.

I hope this works for you.

Greetings,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
GlenB
Top achievements
Rank 1
answered on 16 Jun 2010, 10:55 PM
Thanks, will give that a go.
Tags
Grid
Asked by
GlenB
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
GlenB
Top achievements
Rank 1
Share this question
or