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

ComboBox Change Event Can't Access Other Values of DataSource

1 Answer 461 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
StevenDom
Top achievements
Rank 1
StevenDom asked on 03 Oct 2014, 07:10 PM
I have configured a Kendo ComboBox as follows:

    var junk = $("#junk").kendoComboBox({
        dataTextField: "Code",
        dataValueField: "Id",
        dataSource: {
            type: "json",
            //serverFiltering: true,
            transport: {
                read: {
                    url: "myServlet?action=ReadJunk",
                    contentType: "application/json;charset=utf-8",
                    dataType: "json"
                }
            },
            schema: {
                model: {
                    id: "Id",
                    fields: {
                        Id: {
                            type: "integer"
                        },
                        Code: {
                            type: "string"
                        },
                        shortDescription: {
                            type: "string"
                        }
                    }
                }
            }
        },
        change: function(e){
            // in here I want to set the ShortDesc widget's content to the selected shortDescription
            $("#ShortDesc").value = "shortDescription";  // this doesn't work
        }
    }).data("kendoComboBox");



The values ID, Code, and shortDescription are properly being returned by my Java Servlet. In the change event I would like set the value of another control to the value of shortDescription that is associated with the selected ComboBox item. What is the proper format for accessing this value?

Thanks

Steven

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 07 Oct 2014, 07:46 AM
Hello Steven,

If I understand you correctly, you would like to get the selected data item. If my assumption is correct, you can use the widget dataItem method:
change: function(e){
     var dataItem = e.sender.dataItem();
 
     if (dataItem) {
            $("#ShortDesc").value = dataItem.shortDescription;
     }
}

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
ComboBox
Asked by
StevenDom
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or