Completed
Last Updated: 13 Sep 2021 11:00 by ADMIN
Release 2021.R3
John
Created on: 13 May 2021 06:25
Category: ComboBox
Type: Bug Report
0
A request triggered by an empty virtualized ComboBox causes a server exception

Bug report

Regression introduced in R2 2020. Possibly related to #5467

Reproduction of the problem

  1. Set up a ComboBox that uses virtualization:
<input id="orders" style="width: 100%" />

<script>
    $(document).ready(function() {
        $("#orders").kendoComboBox({
            dataTextField: "ProductName",
            dataValueField: "ProductID",
            virtual: {
                itemHeight: 26,
                valueMapper: function(options) {
                    $.ajax({
                        url: "Home/Orders_ValueMapper",
                        type: "GET",
                        dataType: "json",
                        data: convertValues(options.value),
                        success: function (data) {
                            options.success(data);
                        }
                    })
                }
            },
            height: 520,
            dataSource: {
                transport: {
                    read: {
                        url: "Home/Virtualization_Read",
                        dataType: "json" 
                    }
                },
                schema: {
                    model: {
                        fields: {
                            ProductID: { type: "number" },
                            ProductName: { type: "string" },
                        }
                    },
                    data: "Data",
		    total: "Total"
                },
                pageSize: 80,
                serverPaging: true,
                serverFiltering: true
            }
        });
    });

    function convertValues(value) {
        var data = {};

        value = $.isArray(value) ? value : [value];

        for (var idx = 0; idx < value.length; idx++) {
            data["values[" + idx + "]"] = value[idx];
        }

        return data;
    }
</script>
  1. Return an empty collection:
public ActionResult Virtualization_Read([DataSourceRequest] DataSourceRequest request)
{
    return Json(GetProducts().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

public IEnumerable<Product> GetProducts()
{
    var products = Enumerable.Range(0, 0).Select(i => new Product
    {
        ProductID = i,
        ProductName = "ProductName" + i
    });

    return products;
}
  1. Focus the ComboBox input and press Down Arrow

Current behavior

A request to the Read action is sent with the following parameters:
http://localhost:54962/Home/Virtualization_Read?take=0&skip=NaN&page=NaN&pageSize=0&filter%5Blogic%5D=and

The NaN value of the parameters: skip=NaN&page=NaN causes a server error:

Input string was not in a correct format.
...
[Exception: NaN is not a valid value for Int32.]

Expected/desired behavior

No exception should be thrown. In versions prior to R2 2020 a request is not sent to the server on pressing Down arrow key.

Environment

  • Kendo UI version: 2021.2.511
  • jQuery version: x.y
  • Browser: [all]
0 comments