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

2 posts, 0 answers
  1. Mike
    Mike avatar
    5 posts
    Member since:
    Nov 2015

    Posted 04 Nov 2015 Link to this post

    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.

  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 06 Nov 2015 Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top