kendo-labs / knockout-kendo

A project to create a robust set of Knockout.js bindings for the Kendo UI widgets.
http://kendo-labs.github.com/knockout-kendo/
274 stars 144 forks source link

How to restrict kendo multiselect to single selection #246

Open MaheshShetty123 opened 7 years ago

MaheshShetty123 commented 7 years ago

Hi, I have implemented kendo knockout multiselect to my project. But I can't able to figure out how to restrict the selection option.

below is my recent knockout kendo code

my earlier kendo code looks like this

    $("#" + id).kendoMultiSelect({
        placeholder: "Select Time Periods ...",
        dataTextField: "TpDescription",
        dataValueField: "TpTimeperiodId",
        autoBind: true,           
        change: function (e) {
            var id = this.element.attr("id");
            competititveAnalysisViewModel.findGraphItem(id);
        },
        open: function (e) {
            if (this.value().length == 1)
                e.preventDefault();   // here i m restricting the selection. How to acheive by using knockout                                                      
        },
        dataSource: trailingTimePeriods
    });     

How to achive by using knockout kendo . Please help me out

Thanks, Mahesh

irega commented 7 years ago

Hi, @MaheshShetty123 your code is valid for "knockout-kendo" too. I have done this fiddle for you: https://jsfiddle.net/ireinoso/k24ww6dh/7/