Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.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
Asp.net mvc 3 如何在Telerik MVC扩展的网格中使用命令列中的不同操作_Asp.net Mvc 3_C# 4.0_Telerik Grid - Fatal编程技术网

Asp.net mvc 3 如何在Telerik MVC扩展的网格中使用命令列中的不同操作

Asp.net mvc 3 如何在Telerik MVC扩展的网格中使用命令列中的不同操作,asp.net-mvc-3,c#-4.0,telerik-grid,Asp.net Mvc 3,C# 4.0,Telerik Grid,我使用的是Telerik MVC扩展版本2012.1.419.340。我在网格中的命令列有问题。我将使用Telerik网站上的示例代码来解释我的问题 我的看法是: @model IEnumerable<Order> @(Html.Telerik().Grid(Model) .Name("Grid") .Columns(columns => { columns.Bound(o => o.OrderID).Width(100); columns.Bound(o

我使用的是Telerik MVC扩展版本2012.1.419.340。我在网格中的命令列有问题。我将使用Telerik网站上的示例代码来解释我的问题

我的看法是:

@model IEnumerable<Order>
@(Html.Telerik().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
    columns.Bound(o => o.OrderID).Width(100);
    columns.Bound(o => o.ShipAddress);
    columns.Command(commands => commands
                .Custom("viewDetails")
                .Text("View Details")
                .DataRouteValues(route => route.Add(o => o.OrderID).RouteKey("orderID"))
                .Ajax(true)
                .Action("ViewDetails", "Grid"))
            .HtmlAttributes(new { style = "text-align: center" })
            .Width(150);
})
.ClientEvents(events => events.OnComplete("onComplete"))
.DataBinding(dataBinding => dataBinding.Ajax().Select("_CustomCommand", "Grid"))
.Pageable()
.Sortable()
.Filterable()
我希望我的命令列根据CanEdit值使用不同的操作。例如,如果CanEdit为false,则使用action

columns.Command(commands => commands
                .Custom("viewDetails")
                .Text("View Details")
                .DataRouteValues(route => route.Add(o => o.OrderID).RouteKey("orderID"))
                .Ajax(true)
                .Action("ViewDetails", "Grid"))
            .HtmlAttributes(new { style = "text-align: center" })
columns.Command(commands => commands
                .Custom("editDetails")
                .Text("Edit Details")
                .DataRouteValues(route => route.Add(o => o.OrderID).RouteKey("orderID"))
                .Ajax(true)
                .Action("EditDetails", "Grid"))
            .HtmlAttributes(new { style = "text-align: center" })
如果CanEdit为true,则使用操作

columns.Command(commands => commands
                .Custom("viewDetails")
                .Text("View Details")
                .DataRouteValues(route => route.Add(o => o.OrderID).RouteKey("orderID"))
                .Ajax(true)
                .Action("ViewDetails", "Grid"))
            .HtmlAttributes(new { style = "text-align: center" })
columns.Command(commands => commands
                .Custom("editDetails")
                .Text("Edit Details")
                .DataRouteValues(route => route.Add(o => o.OrderID).RouteKey("orderID"))
                .Ajax(true)
                .Action("EditDetails", "Grid"))
            .HtmlAttributes(new { style = "text-align: center" })
你能告诉我如何实施吗


谢谢

最后我通过在网格中使用模板列解决了这个问题。我发现没有办法根据需要更改命令列的文本。谢谢