Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将剑道网格与Azure上托管的web api绑定时出现问题_Azure_Asp.net Web Api_Kendo Ui_Kendo Grid - Fatal编程技术网

将剑道网格与Azure上托管的web api绑定时出现问题

将剑道网格与Azure上托管的web api绑定时出现问题,azure,asp.net-web-api,kendo-ui,kendo-grid,Azure,Asp.net Web Api,Kendo Ui,Kendo Grid,我正在努力用Web API绑定剑道网格。Web API托管在尚未发布的Azure worker角色中。Web API经过修饰,以便与跨域(即为Web API启用CORS)一起工作 让我们看看我写的代码 WebAPI中的操作方法如下所示 public JToken Get() { JToken json = JObject.Parse( "{ \"firstName\": \"John\", \"lastName\": \"Smith\",

我正在努力用Web API绑定剑道网格。Web API托管在尚未发布的Azure worker角色中。Web API经过修饰,以便与跨域(即为Web API启用CORS)一起工作

让我们看看我写的代码

WebAPI中的操作方法如下所示

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数据,但是当我使用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
});

我也不例外。

经过长时间的斗争,我终于找到了解决办法:。当我使用剑道格网时,我发现了一件奇怪的事情。每当我们在项目中处理模型并将模型返回到kendogrid的数据源时,它就会在内部为其创建一个模型。正如我在上面使用示例json一样,kendogrid不会创建网格绑定的模型。因此问题就出现了。最后,我得出的结论是,在数据源kendo网格中有一个模式/模型更好。过去我没有:谢谢你

您还没有在网格上声明任何列,您尝试过吗?如果我想要所有列,则不需要特定列。那没关系。就连我也用了专栏,同样的问题。