RadToolBar get_checked() always return "true"

3 posts, 1 answers
  1. Martin
    Martin avatar
    2 posts
    Member since:
    Oct 2014

    Posted 28 Nov 2014 Link to this post

    I've implemented a grid with toolbar and a filtering option. I'd like to turn the grids filter on and off when clicking the toolbar button "Filter".

    Here is the aspx code and the JS function being called on client click. Most of it is from the forum or the documentation:

    <telerik:RadToolBar runat="server" ID="RadToolBar1" OnClientButtonClicked="onButtonClicked"
    EnableViewState="False" ResolvedRenderMode="Classic" SingleClick="none">
            <telerik:RadToolBarButton Text="Open" ImageUrl="~/Images/reply.gif"
                CommandName="openMail" />
            <telerik:RadToolBarButton IsSeparator="true" />
            <telerik:RadToolBarButton CommandName="showFilter" Text="Filter" CheckOnClick="True">

    function onButtonClicked(sender, args) {
        var commandName = args.get_item().get_commandName();
        if (commandName == "showFilter") {
            if (tbButton.get_checked()) {
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().hideFilterItem();
            } else {
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().showFilterItem();

    And I have some code handling other button clicks in VB.

    Private Sub RadToolBar1_ButtonClick(sender As Object, e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar1.ButtonClick
        Dim tbBtn As RadToolBarButton = TryCast(e.Item, RadToolBarButton)
        Select Case tbBtn.CommandName.ToLower
            Case "openmail"
                OnMessageListSelectionChanged(displayedID, True, False)
        End Select
    End Sub

    My problem is that tbButton.get_checked() always returns true. No matter what the current state is. I assume that there is a second request setting it back... Any ideas how to solve it? Or what exactly the problem is?

    Thanks a lot in advance.
  2. Answer
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 01 Dec 2014 Link to this post

    Hey Martin!

    I ran in to this myself once, but managed to solve it pretty easily. I just changed the RadToolBarButton declaration to have one more property, like this:

    <telerik:RadToolBarButton CommandName="showFilter" Text="Filter" CheckOnClick="true" AllowSelfUnCheck="true" />

    The main difference here is the "AllowSelfUnCheck" which I set to true here. The reasoning is that it seems like CheckOnClick simply allows the user to check the button, but does not allow the user to uncheck the same button. So, every time the user clicks it will always come across as checked because the first time it becomes checked when clicked, and all other times will not remove the state.

    Anyways, I found this option by looking in to this documentation article which goes over all of the properties of the different RadToolBar items.

    Hope that helps!
  3. DevCraft R3 2016 release webinar banner
  4. Martin
    Martin avatar
    2 posts
    Member since:
    Oct 2014

    Posted 02 Dec 2014 Link to this post

    Hey Schlurk,

    that worked. Thanks a lot!
Back to Top