Completed
Last Updated: 14 Feb 2020 12:33 by ADMIN
Andy
Created on: 07 Feb 2020 17:25
Category: MultiSelect
Type: Bug Report
0
MultiSelect on adding a new item the dataSource requestEnd event args return "read" type of request

Bug report

When a new item is added and the dataSource's sync method is called, the requestEnd event handler data (arg.type) returns the type of request as "read", instead of "create".
As a result the Add new item demo, does not work as expected, because it has a check for the type of the request in the requestEnd handler, and expects the request to be "create". Since the request type comes out as "read" the logic for selecting the newly added item is not executed.

In previous versions the request has been correctly identified as "create". The issue is exhibited only in the MultiSelect. The ComboBox and the DropDownList return the request as "create".

This behavior has been introduced in R3 2017. Reproducible in Chrome, Firefox and Chromium Edge. Not reproducible in IE11 and Spartan Edge.

As a workaround the addNew function can be modified as shown below:

function addNew(widgetId, value) {
    var widget = $("#" + widgetId).getKendoMultiSelect();
    var dataSource = widget.dataSource;

    if (confirm("Are you sure?")) {
        dataSource.add({
            ProductID: 0,
            ProductName: value
        });
      
        dataSource.one("sync", function() {
          var index = dataSource.view().length - 1;
          var newValue = dataSource.at(index).ProductID;
          
          widget.value(widget.value().concat([newValue]));
        });

        dataSource.sync();
    }
}

Reproduction of the problem

Dojo example.

  1. Open the browser's console.
  2. Focus the input and type in some random text.
  3. Click the button in the popup to add a new item.
  4. The type of the request returned by the requestEnd event data is logged in the console.

Current behavior

The event data returns "read" as the type of the request.

Expected/desired behavior

The event data returns "create" as the type of the request.

Environment

  • Kendo UI version: 2020.1.114
  • jQuery version: x.y
  • Browser: [Chrome XX | Firefox XX | Chromium Edge ]
1 comment
ADMIN
Dimitar
Posted on: 14 Feb 2020 12:33

Hello Andy,

After reviewing the issue, it turned out to be a demo issue and we updated our example, which will be live with R1 2020 SP1. The correct code for handling the Add new item scenario and the actual change are described in the following comment.

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.