Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.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
Jquery 如何在剑道网格中使用fluent接口_Jquery_Asp.net Mvc_Kendo Ui_Kendo Asp.net Mvc - Fatal编程技术网

Jquery 如何在剑道网格中使用fluent接口

Jquery 如何在剑道网格中使用fluent接口,jquery,asp.net-mvc,kendo-ui,kendo-asp.net-mvc,Jquery,Asp.net Mvc,Kendo Ui,Kendo Asp.net Mvc,学习剑道UI。。。我正在玩,它很好地展示了如何使用jQuery设置带有服务器端分页的网格 现在我正在尝试做同样的事情,除了使用服务器端脚本,这样我就可以使用漂亮的Fluent界面(看来Kendo的2014-Q1版本没有提供Intellisense,请参阅评论)。但我无法让网格启动第一个获取数据的调用。以下是我所拥有的: <div id="archiveGrid"> @(Html.Kendo() .Grid<MessageLite>() .Name(

学习剑道UI。。。我正在玩,它很好地展示了如何使用jQuery设置带有服务器端分页的网格

现在我正在尝试做同样的事情,除了使用服务器端脚本,这样我就可以使用漂亮的Fluent界面(看来Kendo的2014-Q1版本没有提供Intellisense,请参阅评论)。但我无法让网格启动第一个获取数据的调用。以下是我所拥有的:

<div id="archiveGrid">
@(Html.Kendo()
      .Grid<MessageLite>()
      .Name("archives")
      .Columns(col =>
               {
                   col.Command(m => m.Custom("View").Click("viewClick")).Width(100);
                   col.Bound(m => m.SenderName).Title("Sender").Width(200);
                   col.Bound(m => m.SenderEmail).Title("Email").Width(200);
                   col.Bound(m => m.SentDate).Title("Sent").Format("{dd MMM yyyy HH:mm").Width(150);
                   col.Bound(m => m.Subject);
               })
      .Scrollable()
      .Pageable(pg => pg.PageSizes(true)
          .ButtonCount(10)
          .Input(true)
          .Refresh(true))
      .DataSource(ds => ds
          .Server()
          .PageSize(15)
          .Read(r=>r.Route("defaultApi").Action("","Messages")) // coming unstuck here, I think
          )
)

</div>
。。。当我使用jQuery语法调用Url
api/messages
时,这非常有效,但当我使用Fluent语法时,它根本无法到达服务器端


我缺少什么?

尝试将
Get
添加到您的
.Action()
,如下所示:

@(Html.Kendo().Grid<kendouimvcapplication1.models.albummodel>()
    .Name("grid")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Get", "Albums"))
    )
    .Pageable()
    .Sortable()
    .Filterable()
)
@(Html.Kendo().Grid())
.名称(“网格”)
.DataSource(DataSource=>DataSource
.Ajax()
.Read(Read=>Read.Action(“获取”、“相册”))
)
.Pageable()
.Sortable()
.可过滤()
)

我建议查看演示如何将剑道UI网格绑定到Web API控制器的教程。

它不喜欢这样。我的读取将发送到
ApiController
,而不是常规控制器,因此它不会路由到
api/messages
,而是尝试路由到
messages/get
,这不起作用。如何调用
read.Action()
来调用
ApiController
?您看过这个问题/答案了吗?+1谢谢!这看起来确实有帮助,但我仍然有两个问题:加载时网格不会立即刷新(我希望如此),如果我单击网格上的“刷新”按钮,它会将整个页面导航到服务器调用的Json结果。显然,其他配置有误……哦,我没有注意到您的绑定设置为
Server()
。将其更改为Ajax,如我上面的示例所示。不,这没有任何区别。仍然不会自动加载。
@(Html.Kendo().Grid<kendouimvcapplication1.models.albummodel>()
    .Name("grid")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Get", "Albums"))
    )
    .Pageable()
    .Sortable()
    .Filterable()
)