2013-11-26 108 views
1

我試圖綁定kendo移動列表視圖與json。 listview正確顯示數據,但是當我嘗試過濾時,出現以下錯誤。Uncaught TypeError:Object [object Object] has no method'toLowerCase'

Uncaught TypeError: Object [object Object] has no method '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":"Beverages"},{"id":0,"type_name":"Meat"},{"id":0,"type_name":"test"},{"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

+0

你可以在某處設置演示嗎? (jsfiddle/jsbin ..) –

回答

相關問題