Anton Kalcik
Anton Kalcik

Reputation: 2206

Get selected index in Kendo UI ComboBox with the TypeScript

I'm missing the possibility to get selected index in the Kendo UI ComboBox with the TypeScript and latest typing definition kendo.all.d.ts (UI for ASP.NET MVC Q1 2014)

var comboBox = $(this).data("kendoComboBox");
if (comboBox) {
    if (comboBox instanceof kendo.ui.ComboBox) {

        var kendoUiComboBox: kendo.ui.ComboBox = <kendo.ui.ComboBox>comboBox;
        kendoUiComboBox.?
    }
}

Upvotes: 0

Views: 2802

Answers (2)

CodingWithSpike
CodingWithSpike

Reputation: 43738

The fundamental problem with TypeScript is that no one maintains these .d.ts definition files. And as you are seeing, even when a company does try to maintain them, sometimes the developers miss things since they have to be maintained by hand. Last time I looked for a jQuery .d.ts file, I found 3 of them in minutes that were all different.

TypeScript gripes aside, you can bypass the compilation and intellisense check by just casting to <any>.

var selected = (<any>kendoUiComboBox).select();

Upvotes: 0

basarat
basarat

Reputation: 276235

Going through the documentation : http://docs.telerik.com/kendo-ui/api/web/combobox select is a getter/setter function.

You should be able to do

var comboBox = $(this).data("kendoComboBox");
if (comboBox) {
    if (comboBox instanceof kendo.ui.ComboBox) {

        var kendoUiComboBox: kendo.ui.ComboBox = <kendo.ui.ComboBox>comboBox;
        var selected = kendoUiComboBox.select();
    }
}

Upvotes: 1

Related Questions