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

RadSearchBox WebMethod Client-side value

1 Answer 252 Views
SearchBox
This is a migrated thread and some comments may be shown as answers.
Gavin
Top achievements
Rank 1
Gavin asked on 08 Nov 2016, 05:10 PM

I have a RadSearchBox that is getting it's values from a WebMethod (in the standard way from the demo), I'm then trying to get the selected value on the client side. However I do not seem to be able to retrieve it. I can get the text easy enough but not the value. Could you please advise how this is done?

 

<telerik:RadSearchBox RenderMode="Lightweight" ID="racProp" runat="server" Width="90%"
              HighlightFirstMatch="true"
              EmptyMessage="[No Property Selected]"
              Filter="Contains"
              TextSettings-SelectionMode="Single"
              InputType="Text"
              MaxResultCount="10"
              OnClientDataRequesting="OnPropertiesClientRequesting"
              OnClientSearch="OnPropertyAdded"  DataKeyNames="Category">
      <WebServiceSettings Method="GetProperties" Path="GetProperties.aspx" />
</telerik:RadSearchBox>

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 11 Nov 2016, 09:50 AM
Hello Gavin,

You could get the value of the item, when you initially select it from the RadSearchBox drop-down. You could do that by handling its OnClientSearch event:
function OnPropertyAdded(sender, args) {
    alert("Selected value: " + args.get_value());
}

Note that if you click afterwords the search button (the magnifier), you will be only able to access the searched text. The reason for that is the fact that the RadSearchBox is designed to facilitate text search and not an item search.

In case you need to search against items, I would suggest you to use the RadAutoCompleteBox control instead. Keep in mind that you will have to implement your own search button for that.

Please, note also, that the RadSearchBox does not have ​InputType and ​TextSettings-SelectionMode properties.

Attached you will find a simple implementation of the discussed.

Regards,
Veselin Tsvetanov
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Tags
SearchBox
Asked by
Gavin
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or