【发布时间】:2014-07-24 21:01:16
【问题描述】:
我正在努力将剑道网格与 Web API 绑定。 Web API 托管在 Azure 辅助角色(尚未发布)中。并且 Web API 被修饰以便与跨域一起工作,即为 Web API 启用 CORS。
让我们看看我写的代码。
Web API 中的操作方法如下所示。
public JToken Get()
{
JToken json = JObject.Parse(
"{ \"firstName\": \"John\",
\"lastName\": \"Smith\",
\"isAlive\": true,
\"age\": 25,
\"height_cm\": 167.6,
\"address\":
{
\"streetAddress\": \"21 2nd Street\",
\"city\": \"New York\",
\"state\": \"NY\",
\"postalCode\": \"10021-3100\"
},
\"phoneNumbers\":
[{
\"type\": \"home\",
\"number\": \"212 555-1234\"
},
{
\"type\": \"office\",
\"number\": \"646 555-4567\"
}]
}"
);
return json;
}
当我执行这个 web api 时,我们将获得 IP 地址为“127.0.0.1”的模拟器,我使用了控制器 "TestController"。
当我在浏览器中执行上面的api时,我得到了完美的JSON数据,但是当我用它来绑定网格时,一切都是徒劳的。
用于绑定数据的代码是
$("#dw_report_container1").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "http://127.0.0.1/test",
dataType: "json"
}
},
},
height: 500,
scrollable: true,
selectable: true
});
我也不例外。
【问题讨论】:
-
您还没有在 Grid 上声明任何列,您尝试过吗?
-
如果我想要所有列,则不需要特定列。那没关系。即使我使用了这些列,同样的问题。
标签: azure asp.net-web-api kendo-ui kendo-grid