Guest User

Untitled

a guest
Jun 18th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <% Html.Grid(Model).Columns(column => {
  2. column.For(x => x.Id).Named("Person ID");
  3. column.For(x => x.Name);
  4. column.For(x => x.Gender);
  5. column.For(x => x.DateOfBirth);
  6. column.For("View Person").Named("").Action(p => { %>
  7. <td style="font-weight:bold">
  8. <%= Html.ActionLink("View Person", "Show", new { id = p.Id })%>
  9. </td>
  10. <% });
  11. }).RowStart((p,row) => {
  12. if (row.IsAlternate) { %>
  13. <tr style="background-color:#CCDDCC">
  14. <% } else { %>
  15. <tr>
  16. <% }
  17. }).Render(); %>
  18.  
  19. public static IGridColumn<T> Action<T>( this IGridColumn<T> column, Func<T, string> viewAction, Func<T, string> editAction, Func<T,bool> editMode )
  20. {
  21. column.CustomItemRenderer = ( context, item ) => context.Writer.Write( "<td>" + ( editMode( item ) ? editAction( item ) : viewAction( item ) ) + "</td>" );
  22. return column;
  23. }
  24.  
  25. <%= Html.Grid( Model.Items ).Columns( column => {
  26. column.For( x => x.Name ).Action(
  27. item => Html.ActionLink( item.Name, "SomeAction" ),
  28. item => Html.TextBox( "Item.Name", item.Name ),
  29. item => ( Model.SelectedItem == item ) );
  30. } )
  31. .Empty("No items found.")
  32. %>
  33.  
  34. <% Html.Grid(Model).Columns(column => {
  35. column.For(x => x.Id).Named("Person ID");
  36. column.For(x => x.Name);
  37. column.For(x => x.Gender);
  38. column.For(x => x.DateOfBirth);
  39. column.For("View Person").Named("").Action(p => { %>
  40. <td style="font-weight:bold">
  41. <%= Html.ActionLink("View Person", "Show", new { id = p.Id })%>
  42. </td>
  43. <% });
  44. }).RowStart((p,row) => {
  45. if (row.IsAlternate) { %>
  46. <tr style="background-color:#CCDDCC">
  47. <% } else { %>
  48. <tr>
  49. <% }
  50. }).Render(); %>
Add Comment
Please, Sign In to add comment