TypeError:r.getClientRects不是函数

Aak*_*kur 7 html javascript toolbar kendo-ui kendo-ui-grid

我试图在此链接后在KendoUI网格中创建一个自定义工具栏:http://demos.telerik.com/kendo-ui/grid/toolbar-template 但遇到错误.

这就是我在我的代码中尝试做的事情:

<div id="example">
    <script type="text/x-kendo-template" id="template">
        <div class="toolbar">
            <label class="category-label" for="category">Show products by category:</label>
            <input type="search" id="category" style="width: 150px" />
        </div>
    </script>
    <div id="grid"></div>
    <script>
        $(document).ready(function () {
            var grid = $("#grid").kendoGrid({
                dataSource: {

                    transport: {
                        read: {
                            url: 'http://localhost:52738/Default1/KendoDataAjaxHandle',
                            type: "post",
                            dataType: "json"
                        }
                    },
                    schema: {
                        data: "Data",
                        total: function (response) {
                            return $(response.Data).length;
                        }
                    },
                    pageSize: 10
                },
                toolbar: kendo.template($("#template").html()),
                groupable: true,
                sortable: true,
                pageable: {
                    refresh: true,
                    pageSizes: true,
                    buttonCount: 5
                },
                columns: [
                            {
                                field: "CustomerAltID",
                                filterable: true
                            },
                            {
                                field: "CustomerID",
                                title: "Customer ID"
                            },

                            {
                                field: "CustomerName",
                                title: "Customer Name",

                                template: "<div class='customer-photo'" +
                                                            "style='background-image: url(../Content/Images/customerimg/#:data.CustomerID#.jpg);'></div>" +
                                                        "<div class='customer-name'>#: CustomerName #</div>"
                            },
                            {
                                field: "Gender",
                                title: "Gender",
                                template: "<div class='gender-photo'" +
                                                            "style='background-image: url(../Content/Images/#:data.Gender#.jpg);'></div>" 

                            }
                ]
            });
            var dropDown = grid.find("#category").kendoDropDownList({
                dataTextField: "Gender",
                dataValueField: "CustomerID",
                autoBind: false,
                optionLabel: "All",
                dataSource: {

                    severFiltering: true,
                    transport: {
                        read: {
                            url: 'http://localhost:52738/Default1/KendoDataAjaxHandle',
                            type: "post",
                            dataType: "json"
                        }
                    },
                    schema: {
                        data:"Data"
                    }
                },
                change: function () {
                    var value = this.value();
                    if (value) {
                        grid.data("kendoGrid").dataSource.filter({ field: "CustomerID", operator: "eq", value: parseInt(value) });
                    } else {
                        grid.data("kendoGrid").dataSource.filter({});
                    }
                }
            });
        });
    </script>
</div>
Run Code Online (Sandbox Code Playgroud)

我不知道问题到底是什么时候我无法找到解决方案.

我使用以下版本 - Jquery v-3.1和Jquery UI - 1.12

Dre*_*ams 15

这个github问题https://github.com/jquery/jquery/issues/3157中提到的另一个答案是包含<script src="https://code.jquery.com/jquery-migrate-3.0.0.min.js"></script>在html中.这对我有用


The*_*hen 7

该问题可能是由于使用jQuery v3.1

Kendo目前正式不支持jQuery v3。但是,如果您还包含jquery-migrate,则显然可以使用。 http://www.telerik.com/forums/jquery-3-0

此处列出了官方支持的jQuery版本:http : //docs.telerik.com/kendo-ui/intro/installation/prerequisites#supported-jquery-versions 请注意,它指出Kendo R3 2016 SP2也应与jQuery 3.1一起使用。 .1。

这样你就可以:

  1. 使用您使用的任何Kendo版本随附的jQuery版本/受其支持的版本
  2. 或将jQuery 3.1与jquery-migrate一起使用
  3. 或使用Kendo R3 2016 SP2和jQuery 3.1。1个