OnClientSearch Get Value

2 posts, 0 answers
  1. Chris Salas
    Chris Salas avatar
    46 posts
    Member since:
    Oct 2009

    Posted 16 Aug 2013 Link to this post

    I have the following SearchBox defined:
    <telerik:RadSearchBox ID="radSBKeywords" runat="server" Skin="MetroTouch" OnClientSearch="Search_ClientSearch" DataValueField="HREF" DataTextField="Name" DataKeyNames="Name,HREF">
        <WebServiceSettings Path="../../WebServices/Telerik_WS.asmx" Method="GetSearchItems" />
        <DropDownSettings Height="300">
            <HeaderTemplate>
                <b><a href="javascript:ClickSearchButton();">See All Results or Choose Below</a></b>
            </HeaderTemplate>
            <ClientTemplate>
                <span class="searchText">#= Type # - #= Name #</span>
            </ClientTemplate>
        </DropDownSettings>
    </telerik:RadSearchBox>

    When i hit the OnClientSearch event i want to get the value that being selected from the dropdown.  Currently i can not get any data out of the get_text, get_value functions.  How do i get the value out of the selection?
  2. Chris Salas
    Chris Salas avatar
    46 posts
    Member since:
    Oct 2009

    Posted 19 Aug 2013 Link to this post

    I have figured my issues and thought i would share.  I ended up checking if an item was highlighted and pulling an HREF attribute from the template and if no sender then redirecting to a search page and pulling the text from the input.
    function Search_ClientSearch(sender, eventArgs) {
        if (sender) {
            if ($('li.rsbListItem.rsbListItemTemplate.rsbListItemHovered').length > 0) {
                sender._element.control._postBackOnSearch = false;
                $('li.rsbListItem.rsbListItemTemplate.rsbListItemHovered span.searchText').children().each(function (i) {
                    $telerik.$('#radSBKeywords_Input')[0].value = $(this).text();
                    window.location = $(this).attr('href');
                });
            }
        }
        else {
            window.location = "/search/results_mss.aspx?q=" + $telerik.$('#radSBKeywords_Input')[0].value;
        }
    }

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