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

RadGrid doesn't do anything with RadToolBarButton

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
waircit
Top achievements
Rank 1
Veteran
waircit asked on 07 Jul 2010, 05:59 AM
Hello,

I'm stuck here. I basically have RadToolBar to perform few functions on my RadGrid (such as Clear Filters, Export to Pdf, etc).

I handled the RadToolBarButton click events in the code behind like this:

    Protected Sub RadToolBar1_ButtonClick(ByVal sender As ObjectByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar1.ButtonClick 
        If TypeOf e.Item Is RadToolBarButton Then 
            Dim button As RadToolBarButton = TryCast(e.Item, RadToolBarButton) 
 
            If button.CommandName = "FullList" Then 
                For Each column As GridColumn In RadGrid1.MasterTableView.Columns 
                    column.CurrentFilterFunction = GridKnownFunction.NoFilter 
                    column.CurrentFilterValue = String.Empty 
                Next 
                RadGrid1.MasterTableView.FilterExpression = String.Empty 
                RadGrid1.MasterTableView.Rebind() 
 
            ElseIf button.CommandName = "ExportToPdf" Then 
                RadGrid1.MasterTableView.ExportToPdf() 
            End If 
        End If 
    End Sub 

My aspx:

   <telerik:RadToolBar runat="server" ID="RadToolBar1" OnButtonClick="RadToolBar1_ButtonClick" onclientButtonClicking="radToolBarClientClicked"
        <Items> 
            <telerik:RadToolBarButton Text="Full List" CommandName="FullList" ImageUrl="~/Images/AwardsGrid/Table.gif"></telerik:RadToolBarButton> 
            <telerik:RadToolBarButton Text="Print" CommandName="Print" ImageUrl="~/Images/AwardsGrid/Printer.gif"></telerik:RadToolBarButton> 
            <telerik:RadToolBarButton Text="Export to Pdf" CommandName="ExportToPdf" ImageUrl="~/Images/AwardsGrid/Printer.gif"></telerik:RadToolBarButton> 
        </Items> 
    </telerik:RadToolBar> 
 
    <telerik:RadGrid ID="RadGrid1" runat="server" ShowStatusBar="true" GridLines="Both" CssClass="RadGridCustomClass" AllowFilteringByColumn="true" OnItemCommand="RadGrid1_ItemCommand" >  
        <!-- my RadGrid contents --> 
    </telerik:RadGrid> 

Funny thing is when I debug, the event is captured. However after it finishes executing, nothing happens.. (filters are not cleared, no pdf exported) etc. Basically it does nothing.


However if I use normal buttons (not RadToolBar) like this:
    <asp:LinkButton ID="LinkButton3" runat="server" type="button" Text="[ Export to Pdf ]" 
        OnClick="LinkButton3_ButtonClick" Font-Underline="false" ForeColor="Black" /> 

    Protected Sub LinkButton3_ButtonClick(ByVal sender As ObjectByVal e As EventArgs) Handles LinkButton3.Click 
        RadGrid1.MasterTableView.ExportToPdf() 
    End Sub 

I can get the pdf exported.

Any idea why and how to fix it?

One more thing, I tried clearing filters using client javascript :

            function RefreshGrid() { 
                var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); 
                masterTable.filter("AwardID""", Telerik.Web.UI.GridFilterFunction.StartsWith, true); 
                masterTable.filter("AwardName""", Telerik.Web.UI.GridFilterFunction.StartsWith, true); 
            } 

It works, but the my current filter setting is gone. It becomes 'No Filter' . How do I persist my default filter?


Thanks!

Andreas

1 Answer, 1 is accepted

Sort by
0
waircit
Top achievements
Rank 1
Veteran
answered on 07 Jul 2010, 06:30 AM
Sorry, I fixed this by removing RadToolBar1 in RadAjaxManager :p The buttons are working now.
Tags
Grid
Asked by
waircit
Top achievements
Rank 1
Veteran
Answers by
waircit
Top achievements
Rank 1
Veteran
Share this question
or