Kendo MultiSelect - Multiple selections with "Enter key"

2 posts, 0 answers
  1. Justin
    Justin avatar
    1 posts
    Member since:
    Apr 2016

    Posted 27 Apr Link to this post

    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);
        };

  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 29 Apr Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top