This is a migrated thread and some comments may be shown as answers.

[Solved] Custom Command with server binding

0 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
dani
Top achievements
Rank 1
dani asked on 08 May 2012, 07:47 PM
RESOLVED - Once removing Ajax needed to remove [HttpPost] from the Action.

1st Q. - I've added custom command to grid with server binding.
When I use Ajax(True) it works, but nothing happens to the grid.
I need to manually refresh the page to have it updated.
When I use Ajax(false)
I get a 404 error.

2nd Q. - I used cell action to hide the command when the status is canceled. This doesn't work as well.

Here is the grid code:

@(Html.Telerik().Grid(Model.myModel).Name("myModel")
.DataKeys(dk =>
    {
        dk.Add(g => g.DealID).RouteKey("DealID");
    })
        .PrefixUrlParameters(false)
 
        .Columns(c =>
            {
                c.Bound(o => o.DealID).Hidden(true);
         
                c.Bound(o => o.DealStatus.StatusName).Title("Status").ReadOnly();
 
                c.Bound(o => o.Remarks).Title("Remarks").ReadOnly();
 
                c.Command(p =>
 
                   p.Custom("cancelDeal")
                    
                       // Set the text of the button
                    .Text("Cancel Deal")
                       // Specify which fields from the bound data item to include in the route (pass as action method arguments)
                    .DataRouteValues(route => route.Add(o => o.DealID).RouteKey("myDealID"))
                   
                       // Make ajax requests
                    .Ajax(false)
                       // Which action method to call
                    .Action("CancelDeal", "MyController")).Title("Cancel"); 
 
            }).CellAction(cell =>
            {
                if ((cell.Column.Title == "Cancel") && (cell.DataItem.DealStatusID.Equals(SafeHedge.Shared.Enums.eDealStatus.DS_Closed) || cell.DataItem.DealStatusID.Equals(SafeHedge.Shared.Enums.eDealStatus.DS_Removed)))
                {
                    cell.HtmlAttributes["style"] = "visibility:hidden";
                }
            }))
Tags
Grid
Asked by
dani
Top achievements
Rank 1
Share this question
or