我需要将按钮添加到kendo网格工具栏,该按钮将在点击时显示弹出窗口。我还需要将这个网格包裹在一个帮助器中,该帮助器将使用此按钮返回网格。该proplem是我需要传递参数的行动,它显示弹出窗口(网格类型是具体的),但我不能使用剃刀语法作为这个助手在* .cs文件中定义,我找不到方法通过常规的c#来完成。我能以某种方式做到这一点吗?下面是代码:将参数传递给使用纯c的Kendo网格工具栏中的动作#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Web;
using System.Web.Mvc;
using Kendo.Mvc.UI;
namespace Test.WebUI.Helpers
{
public static class ExtendedGridHelper
{
public static Kendo.Mvc.UI.Fluent.GridBuilder<T> ExtendedGrid<T>(this HtmlHelper helper, string name, Tuple<string, string> dataAccessing)
where T : class
{
return helper.Kendo().Grid<T>()
.Name(name)
//.DataSource(src => src.Ajax().Read(read => read.Action("GetInstances", "ExtendedGrid")))
.DataSource(src => src.Ajax().Read(dataAccessing.Item1, dataAccessing.Item2))
.Sortable()
.Pageable(it => it.PageSizes(true))
.Groupable()
.Filterable()
.Reorderable(it => it.Columns(true))
.Scrollable(it => it.Virtual(true))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Columns(columns =>
{
foreach (var property in typeof (T).GetProperties().OrderBy(it => it.Name))
{
columns.Bound(property.Name).Width(150);
}
}
)
.ToolBar(toolbar =>
{
toolbar.Custom().Action("ViewPopup", "ExtendedGrid").Text("Settings").HtmlAttributes(new {@class = "modal-link btn btn-success"});
//This way it works, but I nered to pass parameter.
}
);
}
}
}
下面是使用的例子:
@(Html.ExtendedGrid<ololo>("Grid1", new Tuple<string, string>("GetInstances", "ExtendedGrid")))
难道你们就不能只是把'@using Test.WebUI.Helpers'到您想要使用这个助手的意见? – 2014-10-31 17:08:36
@BenRobinson,对不起,但它会有帮助吗? – KorsaR 2014-10-31 17:26:52