未捕获的TypeError:Object [object Object]没有方法'toLowerCase'

时间:2013-11-26 14:19:50

标签: jquery json telerik kendo-ui kendo-mobile

我正在尝试用json绑定kendo mobile listview。 listview正确显示数据,但当我尝试过滤时,我收到以下错误。

  

未捕获TypeError:对象[object Object]没有方法'toLowerCase'

 <div data-role="view" data-init="mobileListViewPullToRefresh" data-title="Pull to refresh" id="typelist">
        <header data-role="header">
            <div data-role="navbar">
                <span data-role="view-title"></span>
                <a data-align="left" data-icon="add" data-role="button" data-rel="modalview" href="#modalview-add"></a>

            </div>
        </header>

        <ul id="pull-to-refresh-listview" data-role="listview" data-style="inset"></ul>
    </div>

    <div data-role="modalview" id="modalview-add" style="width: 95%; height: 12em;">
        <div data-role="header">
            <div data-role="navbar">
                <span>Add Type</span>
                <a data-click="closeModalViewAdd" data-role="button" data-align="right">Cancel</a>
            </div>
        </div>

        <ul data-role="listview" data-style="inset">
            <li>
                <label for="username">Type Name:</label>
                <input type="text" id="txtTypeName" /></li>
        </ul>
        <a data-click="addNew" class="addNew" type="button" id="btnaddType" data-role="button">Add New Type</a>
    </div>

    <script type="text/javascript">
        $(document).ready(function () {

            //get type start
            loadtypes();

            function loadtypes() {

                $("#pull-to-refresh-listview").empty();
                var murl = "/Home/getTypes/";
                $.ajax({
                    url: murl,
                    cache: false,
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType: 'json',
                    success: function (data) {
                        var dataSource = new kendo.data.DataSource({ data:data });
                         $("#pull-to-refresh-listview").kendoMobileListView({
                            dataSource: dataSource,
                            template: "#: type_name #",
                            filterable: true,
                            virtualViewSize: 50 // needed setting, since local data virtualization does not use paging
                        });

                        return dataSource;

                    },
                    error: function (reponse) {
                        return '{"error":"Error"}';
                    }
                });
            }

        });
    </script>

JSON:

  

[{ “ID”:0, “TYPE_NAME”: “饮料”},{ “ID”:0, “TYPE_NAME”: “肉”},{ “ID”:0, “TYPE_NAME”: “测试” },{ “ID”:0, “TYPE_NAME”: “TEST2”},{ “ID”:0, “TYPE_NAME”: “TEST3”},{ “ID”:0, “TYPE_NAME”: “TEST4”}, { “ID”:0, “TYPE_NAME”: “TEST5”},{ “ID”:0, “TYPE_NAME”: “TEST7”},{ “ID”:0, “TYPE_NAME”: “test8”},{” ID “:0,” TYPE_NAME “:” TYPE6" }]

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以从剑道论坛帮助这篇文章:Filtering causes "Uncaught TypeError: Object xxx has no method 'toLowerCase'"。我遇到了同样的问题并且有效。