2014-07-03 72 views
0

我試圖按照本教程將kendo UI datagrid綁定到我的azure後端移動服務表(SASA)。 http://ignaciofuentes.com/archive/2014/01/20/zumo-kendo/ 但不幸的是,由於某些原因,它無法正常工作。我已經嘗試更新從1.0.0到1.1.5的移動服務JavaScript SDK仍然沒有運氣。無法將kendo datagrid數據源綁定到Azure移動服務?

這裏是我的代碼..任何人都可以指出我在做什麼錯..服務正在返回正確的JSON ..

<!DOCTYPE html> 
<html> 
<head> 
<base href="http://demos.telerik.com/kendo-ui/grid/everlive"> 
<style>html { font-size: 12px; font-family: Arial, Helvetica, sans-serif; }</style> 
<title></title> 
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.1.528/styles/kendo.common.min.css"> 
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.1.528/styles/kendo.default.min.css"> 
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.1.528/styles/kendo.dataviz.min.css"> 
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.1.528/styles/kendo.dataviz.default.min.css"> 
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 
<script src="http://cdn.kendostatic.com/2014.1.528/js/kendo.all.min.js"></script> 

 <div id="example"> 
     <div id="grid"></div> 
     <script> 
      $(document).ready(function() { 
var client = new WindowsAzure.MobileServiceClient("MY SERVICE URL", "MY API KEY"); 
var table = client.getTable("sasa"); 
var dataSource = new kendo.data.DataSource({ 
transport: { 
    read: function (options) { 
     table.includeTotalCount() //necessary for grid to paginate 
      .read() 
      .done(options.success); 
    }, 
    update: function (options) { 
     table.update(options.data) 
      .done(options.success); 
    }, 
    create: function (options) { 
     var item = options.data; 
     delete item.id; //ZUMO doesnt allow you to set your own ID. It gets auto generated. 
     table.insert(item) 
      .done(options.success); 
    }, 
    destroy: function (options) { 
     table.del(options.data) 
      .done(options.success); 
    } 
}, 
pageSize: 10, 
schema: { 
    total: "totalCount", 
    model: { 
     id: "id", 
     fields: { 
      id: { type: "number" }, 
      name: { type: "string" }, 
      developer: { type: "string" }, 
     } 
    } 
}}); 

$("#grid").kendoGrid({ 
pageable: true, 
dataSource: dataSource, 
columns: [ 
    "name", 
    "developer", { 
    command: [{ 
     name: "edit", 
     text: "Edit" 
    }, { 
     name: "destroy", 
     text: "Delete" 
    }] 
}], 
toolbar: [{ 
    name: "create" 
}], 
editable: "inline" 
});  


     }); 
     </script> 
    </div> 
</body> 
</html> 

回答

0

在一個測試我做了一段時間使用kendo數據源和windows azure移動服務,我的數據源CRUD方法有點不同。

create: function(options) { 
    delete options.data.id; 
    client.getTable("Customer").insert(options.data).done(function(data) { 
     options.success(data); 
    }); 
    }, 
    read: function(options) { 
    client.getTable("Customer").read().done(function(data) { 
     options.success(data); 
    }); 
    }, 
    update: function(options) { 
    client.getTable("Customer").update(options.data).done(function(data) { 
     options.success(data); 
    }); 
    }, 
    destroy: function(options) { 
    client.getTable("Customer").del(options.data).done(function(data) { 
     options.success(data); 
    }); 
    } 

它工作正常。也許嘗試改變.done(options.success);

.done(function(data) { 
    options.success(data); 
}); 

然後看看它是否工作?

--edit我重建了我的MobileService,我曾經測試並挖出代碼,它仍然正常工作。這裏是jsbin的示例http://jsbin.com/jirexo/2/edit

相關問題