TypeError : r.getClientRects is not a function

42.1k views Asked by At

I am trying to create a custom toolbar in KendoUI grid following this link:http://demos.telerik.com/kendo-ui/grid/toolbar-template but getting stuck with an error.

This is what I am trying to do in my code:

<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>

I don't know what the problem is and its been hours that I am unable to figure out the solution for it.

I am using the following versions- Jquery v-3.1 and Jquery UI-1.12

2

There are 2 answers

1
The Dread Pirate Stephen On BEST ANSWER

The problem is likely due to using jQuery v3.1

Kendo does not currently work with jQuery v3, officially. But it apparently can work if you also include jquery-migrate. http://www.telerik.com/forums/jquery-3-0

The officially supported versions of jQuery are listed here: http://docs.telerik.com/kendo-ui/intro/installation/prerequisites#supported-jquery-versions Note that it states that Kendo R3 2016 SP2 should also work with jQuery 3.1.1.

So, you can:

  1. use the version of jQuery that ships with/is supported by whatever version of Kendo you use
  2. OR use jQuery 3.1 with jquery-migrate
  3. OR use Kendo R3 2016 SP2 and jQuery 3.1.1
1
Dreams On

Another possibility as mentioned in this github issue is to include <script src="https://code.jquery.com/jquery-migrate-3.0.0.min.js"></script> in html. This worked for me.