This question is locked. New answers and comments are not allowed.
Hi
I am using Telerik MVC extension version 2012.1.419.340 (trial). I had a problem with Command Column in Grid. I will use the example code on your website to explain my problem.
I have view like:
and my Order model like
I would like my Command Column to use different Action depending on CanEdit value. For example, if CanEdit is false, using action
if CanEdit is true, using action
Can you give me some idea how to implement it?
Thanks
I am using Telerik MVC extension version 2012.1.419.340 (trial). I had a problem with Command Column in Grid. I will use the example code on your website to explain my problem.
I have view like:
@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()
)
and my Order model like
public
class
Order{
public
int
OrderID {
get
;
set
;}
public
string
ShipAddress {
get
;
set
; }
public
bool
CanEdit {
get
;
set
;}
}
I would like my Command Column to use different Action depending on CanEdit value. For example, if CanEdit is false, using 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"
})
if CanEdit is true, using action
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"
})
Can you give me some idea how to implement it?
Thanks