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

Getting the value of 3 columns from a multi-column combobox

1 Answer 584 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 04 Nov 2015, 05:29 PM

Hi telerik team,

I've a Multi-column comboBox and I need to get the value of 3 of the columns when the user select one item in JavaScript.

Here's my comboBox code:

01.@(Html.Kendo().ComboBox()
02.    .Name("comboBox1")
03.    .Events(x => x.Change("comboBox1_onChange"))
04.    .DataValueField("ID")
05.    .DataTextField("Description")
06.    .HeaderTemplate(
07.        "<div class=\"dropdown-header\">" +
08.        "<span class=\"k-widget k-header\">ID</span>" +
09.        "<span class=\"k-widget k-header\">Reference</span>" +
10.        "<span class=\"k-widget k-header\">Description</span>" +
11.        "<span class=\"k-widget k-header\">Internal Code</span>" +
12.        "</div>")
13.    .Template(
14.        "<span class=\"columnItem\">#: data.ID #</span>" +
15.        "<span class=\"columnItem\">#: data.Reference #</span>" +
16.        "<span class=\"columnItem\">#: data.Description #</span>" +
17.        "<span class=\"columnItem\">#: data.InternalCode#</span>")
18.    .Filter(FilterType.StartsWith)
19.    .DataSource(source => {
20.        source.Custom()
21.        .ServerFiltering(true)
22.        .ServerPaging(true)
23.        .PageSize(80)
24.        .Type("aspnetmvc-ajax") //Set this type if you want to use DataSourceRequest and ToDataSourceResult instances
25.        .Transport(transport =>
26.        {
27.            transport.Read("ProductsVirtualization_Read", "Edit");
28.        })
29.        .Schema(schema =>
30.        {
31.            schema.Data("Data") //define the [data](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.data) option
32.            .Total("Total"); //define the [total](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.total) option
33.        });
34.    })
35.    .Virtual(v => v.ItemHeight(26))//.ValueMapper("valueMapper"))
36.)

 

Can anyone give me a clue about how to read the value of "ID", "Reference" and "InternalCode" in the comboBox1_onChange event?

Thank you.

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 06 Nov 2015, 10:02 AM

Hello Mike,

 

You can call the value() method that will return the selected value and just grep in the array to find the corresponding data item. Please see the following example:

 

http://dojo.telerik.com/agOXo

 

Regards,
Kiril Nikolov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ComboBox
Asked by
Mike
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or