Posted By

rogalski on 10/14/10


Tagged

c aspnet MVC grid


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


MVCContrib Grid Usage


 / Published in: C#
 

URL: http://mvccontrib.codeplex.com/wikipage?title=Grid&referringTitle=Documentation

Example usage

  1. <div>
  2. <%=
  3. Html.Grid<ReportingGroup>("reportingGroups")
  4. .Sort(ViewData["sort"] as GridSortOptions)
  5. .RowAttributes(
  6. data=>new Hash(
  7. @title => String.Format("Recipients:{0} Creator:{1} Customer Reporting Name:{2} Number of Configured Items:{3}",
  8. data.Item.ReportingGroupRecipientsAsString,
  9. data.Item.CreatorEmailAddress,
  10. data.Item.ReportingGroupName,
  11. data.Item.ReportingGroupItems.Count
  12. )
  13. )
  14. )
  15. .Columns(column =>
  16. {
  17. column.For(x => x.Id).Attributes(@class => "report-id").Sortable(true);
  18. column.For(x => x.ReportingGroupRecipientsForGrid(40)).Named("Recipients").Attributes(@class => "report-recipients").Sortable(false);
  19. column.For(x => x.CreatorEmailAddress).Named("Creator").Attributes(@class => "report-creator").Sortable(true);
  20. column.For(x => x.ReportingGroupName).Named("Customer Reporting Name").Attributes(@class => "report-name").Sortable(true);
  21. column.For(x => "<a href=\"" + Url.Action("Edit", "ReportingGroup", new { id = x.Id }) + "\" class=\"edit-link\"><img src=\"" + Url.Content("~/Content/images/pencil.png") + "\"/></a>").Named("Edit").Sortable(false).DoNotEncode().Attributes(@class => "report-link-cell");
  22. column.For(x => "<a href=\"" + Url.Action("ConfirmDelete", "ReportingGroup", new { id = x.Id }) + "\" class=\"delete-link\"><img src=\"" + Url.Content("~/Content/images/bin_closed.png") + "\"/></a>").Named("Delete").Sortable(false).DoNotEncode().Attributes(@class => "delete-link-cell");
  23. })
  24. .Empty("No reporting preferences have been found for your user ID.")
  25. %>
  26. <%= Html.Pager("reportingGroups") %>
  27. </div>

Report this snippet  

You need to login to post a comment.