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

Bug in Adding new items to Multiselect using API in "Kendo 2015 Q2" build

3 Answers 325 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Nariman
Top achievements
Rank 1
Nariman asked on 23 Jul 2015, 07:20 PM

Hi Please see my sample code Here (http://dojo.telerik.com/UViSA).

In this sample code, I'm trying to add new item to Multiselect by typing ​any word followed by "," (comma) into the Multiselect textbox. It works well in all the previous builds (2015 Q1, Q1 SP1 and Q1 SP2) but it doesn't work with "Kendo 2015 Q2"!

To reproduce the problem:

1. Run the above example with (Kendo 2015 Q1 SP2).

2. in Multiselect textbox, enter "test" and press "," (comma)

3. You can see the world "test" is added to the Multiselect items and also automatically is selected and displayed.

4. Now change to the (Kendo 2015 Q2) and repeat the above steps 1 and 2, you will see that although, the word "test" is added to the list but:
a) it cannot be selected automatically anymore.
b) the word "test," is no longer cleared automatically in the multiselect textbox
c) basically this.value("test"); is not doing its job anymore!

I would appreciate your support to review and let me know:

1. What's wrong that my code is not working with "2015 Q2"?

2. If there is a better way of doing the code.

Thank you.

My sample code is pasted below as well:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Kendo UI Snippet</title>
 
 
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
   
<select id="multiselect"></select>
   
<script>
var data = [{TagText: "Albania", id: "Albania"},
            {TagText: "America", id: "America"}];
var _savedOld = "";
 
function multiselect_change(e) {
  var previous = _savedOld
  var current = this.value();
  var diff = [];
  if (previous) {
    //check for removed selected items
    diff = $(previous).not(current).get();
    if (diff.length > 0){
      alert("Removed Item = "+diff);
    }else{
      //check for new selected items
      diff = $(current).not(previous).get();
      if (diff.length > 0){
        alert("New Item = "+diff);
        }
    }
    this.refresh();
  }
  _savedOld = current.slice(0);
}
function multiselect_filtering(e) {
  //get filter descriptor
  var filter = e.filter;
  if (filter.value.indexOf(",") > 0){
    var newtag = filter.value.replace(",","");
    var values = this.value().slice();
    this.dataSource.filter({});
    //e.preventDefault();
    this.dataSource.add({ id: newtag, TagText: newtag });
 
    var add = [newtag];
    if (values.length > 0) {
      var merge = $.merge(add,values);
      this.value($.unique(merge));
    }else{
      this.value(add);
    }
    this.trigger("change");
    this.dataSource.refresh();
  }
$("#multiselect").kendoMultiSelect({
  dataTextField: "TagText",
  dataValueField: "id",
    filter: "contains",
  dataSource: data
});
var multiselect = $("#multiselect").data("kendoMultiSelect");
multiselect.bind("filtering", multiselect_filtering); 
multiselect.bind("change", multiselect_change);
_savedOld = multiselect.value(); 
   
  </script>
</body>
</html>

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 27 Jul 2015, 10:04 AM
Hello Nariman,

Since 2015.1.429, we introduced several bug fixes that seems to affect your custom code. Basically, the widget stays in filter mode, hence when the source and value are modified in this state the code breaks. What you will need to do is to disable the filter mode, before modify the source and value manually: Note, how the filter mode is set to false.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Kheng Aik
Top achievements
Rank 1
answered on 07 Jan 2016, 10:24 AM

Hi,

 I have try the your code against Q1 2016 Beta, it doesn't work anymore.

that.listView.filter(false) is not a function.

Kindly advise how to set filter mode to false in new version.

Thanks.

0
Georgi Krustev
Telerik team
answered on 11 Jan 2016, 09:21 AM
Hello,

The demo indeed will not work with newest version of Kendo UI as the filter method from the underlying listView instance was removed, because it is not needed anymore. That being said, the demo will work just fine if you just remove it:
Regards,
Georgi Krustev
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
Nariman
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Kheng Aik
Top achievements
Rank 1
Share this question
or