发送附加参数在剑道网格读动作 [英] Send Additional Parameter in Kendo Grid Read Action

查看:179
本文介绍了发送附加参数在剑道网格读动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个剑道电网如下。

I have a kendo Grid as follows.

@(Html.Kendo().Grid<RevenueModel>()
     .Name("WeeklyRevenue")
     .Resizable(resizing => resizing.Columns(true))
     .Columns(columns =>
         {
            columns.Bound(p => p.Number).Width(100);
            columns.Bound(p => p.Type).Width(100);
            columns.Bound(p => p.Week1).Format("{0:c}");
            columns.Bound(p => p.Week2).Format("{0:c}");
            columns.Bound(p => p.Week3).Format("{0:c}");
            columns.Bound(p => p.Week4).Format("{0:c}");
            columns.Bound(p => p.Week5).Format("{0:c}");
            columns.Bound(p => p.TotalRevenue).Format("{0:c}");
         })
     .Scrollable()
     .Events(events => events.Change("onChange").DataBound("onDataBound"))
     .DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("WeeklyRevenue", "Home")).ServerOperation(false))
     .Pageable(pager => pager.Refresh(true))
 )

下面是我的控制器code

Here is my Controller code

public ActionResult WeeklyRevenue([DataSourceRequest]DataSourceRequest request)
        {
            ...
            DataSourceResult result = res.ToDataSourceResult(request);
            return Json(result, JsonRequestBehavior.AllowGet);
        }

它工作正常。但是,我想送更多的数据时,网格中读取数据,类似下面的;

It works fine. But I want to send additional data when Grid reads data, something like the following;

public ActionResult WeeklyRevenue([DataSourceRequest]DataSourceRequest request, string AdditionalParam)

我找不到任何解决方案是如何做到这一点。先谢谢了。

I couldn't find any solution how to do this. Thanks in advance.

推荐答案

如果额外的数据在服务器端知道你应该使用它接受路由值action方法的重载:

If the additional data is known at server-side you should use the overload of the Action method which accepts route values:

.DataSource(dataSource => dataSource.Server()
   .Read(read => read.Action("Read", "Home", 
        new { AdditionalParam = ViewData["AdditionalParam"] }))
)

如果这个额外的数据在客户端只知道你应该使用数据的方法:

If this additional data is known at the client-side only you should use the Data method:

.DataSource(dataSource => dataSource.Ajax()
   .Read(read => read
      .Action("Read", "Home")
      .Data("additionalData")
  )
)
<script>
 function additionalData() {
     return {
         AdditionalParam: $("#search").val()
     };
 }
</script>

这篇关于发送附加参数在剑道网格读动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆