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

OnClientSearch Get Value

1 Answer 124 Views
SearchBox
This is a migrated thread and some comments may be shown as answers.
Chris Salas
Top achievements
Rank 1
Chris Salas asked on 16 Aug 2013, 06:24 PM
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?

1 Answer, 1 is accepted

Sort by
0
Chris Salas
Top achievements
Rank 1
answered on 19 Aug 2013, 02:39 PM
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;
    }
}

Tags
SearchBox
Asked by
Chris Salas
Top achievements
Rank 1
Answers by
Chris Salas
Top achievements
Rank 1
Share this question
or