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

Searching by multiple DataTextField variables

3 Answers 372 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 04 Mar 2013, 10:59 PM
When using .DataTextField() you are only able to search by one variable. Is there a way to search by multiple?

For instance, using .DataTextField("CorpName") returns a list of items that start with the Corp name and .DataTextField("AccountNumber") returns a list of items that start with Account Number... I would like to return the search by both CorpName and AccountNumber.

I am able to achieve this with autoComplete because each time it does a search, it is querying the database through a webservice and is therefore searching by both fields... but since this is a combobox, it only queries the database once and therefore I need to use .DataTextField() to search the returned list.

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 05 Mar 2013, 01:15 PM
Hello Richard,

 
The ComboBox does not support filtering by multiple fields. Nevertheless, you can enable filtering and use your "autocomplete" approach.

Greetings,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ben
Top achievements
Rank 1
answered on 23 Sep 2017, 02:04 PM

I understand that you can't filter by multiple fields, but is there a way to specify a different field to filter on than the one used in the DataTextField?  I have a combobox that uses templates to display a "dropdown table" so the user can see both the ID and the Description, but when they select and item it needs to display just the ID in the combo box's display.  When they type the letters "AJ" they will find my sample data item below, but if they type "American" it won't find the item because it does not match the ID specified in the DataTextField.  Is there a way to keep "ID" as the DataTextField but have the filter use the field called "Combined"?

@(Html.Kendo().ComboBoxFor(m => m.PublicationId)
    .DataTextField("ID")
    .DataValueField("ID")
    .BindTo(Model.Publications)
    .Filter(FilterType.Contains)
    .TemplateId("pubListItemTemplate")
    .HeaderTemplateId("pubListHeaderTemplate")
)

and my Data "Model.Publications" looks like this:  

[{ ID: "AJ", Description: "American Journal", Combined: "AJ American Journal" }, etc...]

 

 

0
Neli
Telerik team
answered on 25 Sep 2017, 11:17 AM
Hello Ben,

If custom filtering different than the DataTextField is needed than the filtering event of the widget should be handled and its default behavior should be canceled. After that, the the DataSource filter method is used for implementing the filters according to the requirements. 

Similar issue is discussed in the following Forum thread.

I hope that the attached Dojo example will be helpful.
 

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