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

Kendo MultiSelect - Multiple selections with "Enter key"

1 Answer 392 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 27 Apr 2016, 07:06 AM

I believe this is due to me data-binding twice, once on initialization for default and another after initialization. I am using both MVC and Javascript... but the javascript is in a different folder.

helper.Kendo().MultiSelect()
                                  .Name(name)
                                  .AutoClose(false)
                                  .Value(selectedValue)
                                  .Placeholder(placeholder)
                                  .DataTextField(dataTextField)
                                  .DataValueField(dataValueField)
                                  .DataSource(
                                    source =>
                                          {
                                              source.Read(read =>
                                              {
                                                  read.Action(methodName, controllerName);
                                              });
                                          });

 

and 

 

resourcesSelect.data("kendoMultiSelect").bind("select", selectAll);

 

After selecting them. When I click it's fine, however on hitting the "enter" key it fires off both selects and selects it twice. Am I looking in the right place? Or is it because of my handler method.

 

function selectAll(e) {
        var dataItem = e.item;
        var values = this.value();

        if (dataItem.text() === "ALL") {
            values = e.sender.dataSource.data().map(function (item) {
                return item.value;
            });
        }
        else {
            var index = $.inArray("ALL",values);
            if (index > -1) {
                values.splice(index, 1);
            }
        }
        this.value(values);
    };

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 29 Apr 2016, 07:34 AM
Hello Justin,

The provided code does not demonstrate the double data-binding. All I see is that the dataSource is being configured in the MVC helper code and the "select" event is bound later.

Could you please provide more detailed code snippets?

The following sentence is also unclear to me:

"I am using both MVC and Javascript... but the javascript is in a different folder."

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