how i get select value from kendo comboBox

Toxic picture Toxic · Feb 20, 2014 · Viewed 32.3k times · Source

i have implented Kendo ComboBox but struggling to get selected value ....

  $("#_FeeScheme_Input").kendoComboBox({
        minLength: 1,
        filter: 'contains',
        dataTextField: "FeeSchemeDescription",
        dataValueField: "FeeSchemeID",
        select: onSelect,
        dataSource: {
            type: "json",
            serverFiltering: false,
            transport: {
                read: "/Qualification/GetAllFeeScheme_JSON"
            },
        }
    });

...

 function onSelect(e) {

        var dataItem = this.dataItem(e.item.index());

        alert("value " + dataItem.text); //NOT WORKING... RETURN NULL VALUE            

    };

Razor code

 <div class="form-group">
                @Html.LabelFor(model => model._FeeScheme.FeeSchemeDescription, new { @class = "control-label col-md-3" })
                <div class="col-md-6">
                    @Html.TextBoxFor(model => model._FeeScheme.FeeSchemeDescription, new { id = "_FeeScheme_Input" })
                    @Html.ValidationMessageFor(model => model._FeeScheme.FeeSchemeDescription)
                </div>
 </div>

Answer

Zolfaghari picture Zolfaghari · Aug 1, 2015
var c = $('#MyCombo');

// to get selected id
c.val() // and also
c.data('kendoComboBox').value()

// to get selected text
c.data('kendoComboBox').text()

// to get selected item index
c.data('kendoComboBox').select()

// to set selected item e.g. 3
c.data('kendoComboBox').select(2)