Kendo网格连接到WebAPI的Json数据集

时间:2013-06-26 16:04:30

标签: json asp.net-mvc-4 asp.net-web-api kendo-grid

本地IIS已安装WebAPI。这是asp.net MVC控制器:

namespace MvcApplication3.Controllers
{
  public class AddressesController : ApiController
  {
    public IEnumerable<Address> GetAllddresses()
    {
        return MvcApplication3.Models.DatabaseAccess.getAddresses();
    }
  }
}

这是Json返回的:

[{"Id":57638,"Address_1":"1226 S STATE ST","Address_2":"","Zip":60605},      
 {"Id":57639,"Address_1":"1240 S STATE ST","Address_2":"","Zip":60605}]

这是网格:

 var AddressList = kendo.data.Model.define({
    fields: {
        Id: "Id",
        Address_1: "Address_1",
        Address_2: "Address_2",
        Zip: "Zip"
    }
});
$("#grid2").kendoGrid({
    dataSource: {
        transport: {
            read: {
                url: "http://localhost/api/addresses"
                dataType: "jsonp"
            }
        },
        Schema: {
            model: AddressList
        }
    }
});            

问题:网格无法绑定到数据

0 个答案:

没有答案