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

Allowing multiple GridAction attributes

1 Answer 90 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.
Nick
Top achievements
Rank 1
Nick asked on 30 Aug 2011, 11:01 PM
I'm trying get a page to allow multiple grids, which is pretty easy to do, but I need to have each use server binding with a custom paging implementation. Logically it makes sense to simple decorate the action with two GridActions each with a unique GridName and ActionParameterName to keep them separate. but the attribute has been flagged as being only allowed once per action. I did find this post covering the same thing (Multiple Grids with Server Binding) but it was last touched almost a year ago. Has there been any progress on the problem since?

My code would look something like this if it would allow me to actually have multiple GridCommands. Any other way to do this?

[GridAction(GridName = "Invoices", ActionParameterName = "invoicesGridCommand")]
[GridAction(GridName = "Payments", ActionParameterName = "paymentsGridCommand")]
public ActionResult Summary(Guid id, GridCommand invoicesGridCommand, GridCommand paymentsGridCommand)
{
    int invoiceCount = 0;
    int paymentCount = 0;
    AccountSummaryModel model = new AccountSummaryModel();
    var invoices = invoiceService.GetInvoicesByClient(id, invoicesGridCommand.Page, invoicesGridCommand.PageSize, out invoiceCount);
    var payments = paymentService.GetPaymentsByClient(id, paymentsGridCommand.Page, paymentsGridCommand.PageSize, out paymentCount);
    model.Invoices = new PagedList<Invoice>(invoices, invoiceCount);
    model.Payments = new PagedList<Invoice>(payments, paymentCount);
    return View(new model);
}


1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 Aug 2011, 08:55 AM
Hi Nick,

 I tried enabling the GridAction attribute to be specified multiple times and code similar as yours worked as expected. You can try changing the source code of the grid:

[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)]

public class GridActionAttribute : FilterAttribute, IActionFilter

Regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Nick
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or