Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <% Html.Grid(Model).Columns(column => {
- column.For(x => x.Id).Named("Person ID");
- column.For(x => x.Name);
- column.For(x => x.Gender);
- column.For(x => x.DateOfBirth);
- column.For("View Person").Named("").Action(p => { %>
- <td style="font-weight:bold">
- <%= Html.ActionLink("View Person", "Show", new { id = p.Id })%>
- </td>
- <% });
- }).RowStart((p,row) => {
- if (row.IsAlternate) { %>
- <tr style="background-color:#CCDDCC">
- <% } else { %>
- <tr>
- <% }
- }).Render(); %>
- public static IGridColumn<T> Action<T>( this IGridColumn<T> column, Func<T, string> viewAction, Func<T, string> editAction, Func<T,bool> editMode )
- {
- column.CustomItemRenderer = ( context, item ) => context.Writer.Write( "<td>" + ( editMode( item ) ? editAction( item ) : viewAction( item ) ) + "</td>" );
- return column;
- }
- <%= Html.Grid( Model.Items ).Columns( column => {
- column.For( x => x.Name ).Action(
- item => Html.ActionLink( item.Name, "SomeAction" ),
- item => Html.TextBox( "Item.Name", item.Name ),
- item => ( Model.SelectedItem == item ) );
- } )
- .Empty("No items found.")
- %>
- <% Html.Grid(Model).Columns(column => {
- column.For(x => x.Id).Named("Person ID");
- column.For(x => x.Name);
- column.For(x => x.Gender);
- column.For(x => x.DateOfBirth);
- column.For("View Person").Named("").Action(p => { %>
- <td style="font-weight:bold">
- <%= Html.ActionLink("View Person", "Show", new { id = p.Id })%>
- </td>
- <% });
- }).RowStart((p,row) => {
- if (row.IsAlternate) { %>
- <tr style="background-color:#CCDDCC">
- <% } else { %>
- <tr>
- <% }
- }).Render(); %>
Add Comment
Please, Sign In to add comment