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

RadSearchBox and DataKeyNames not working

2 Answers 111 Views
SearchBox
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 19 Feb 2018, 01:45 AM

The documentation says I can include more than the one column in the search of my DataTable by using the DataKeyNames property. Maybe I am not understanding but its not working. I have my DataTextField column set to "Name" and my DataKeyNames set to "Alias". I expected the search to go against the Name column and the Alias column but it seems to be only searching the Name column. 

Does not get any simpler scenario than this so I must not be understanding how DataKeyNames works.

DataTable columns: Id, Name, Alias

<telerik:RadSearchBox ID="requestSearchBox" runat="server" Width="400" CssClass="SearchBox" EnableAutoComplete="true"
                            DataValueField ="Id"
                            DataKeyNames= "Alias"
                            DataTextField="Name">
                        </telerik:RadSearchBox>

 

Brian

2 Answers, 1 is accepted

Sort by
0
Brian
Top achievements
Rank 1
answered on 19 Feb 2018, 06:41 PM

Well, seems DataKeyNames are what is returned, not what is searched.

So I guess not what I wanted but I did need this as well.

Brian

0
Vessy
Telerik team
answered on 21 Feb 2018, 04:51 PM
Hi Brian,

Yes, the DataKeyNames property is used for the search result values, you can find details about its funtionality here:
https://docs.telerik.com/devtools/aspnet-ajax/controls/searchbox/functionality/datakeynames

If you want to search in multiple columns, you should pass all of them to the DataKeyNames property, like in this demo:
DataKeyNames="sport,birthday,country"


Regards,
Vessy
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
SearchBox
Asked by
Brian
Top achievements
Rank 1
Answers by
Brian
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or