Advanced Column Rendering for MVCContrib Grid with MVC3 Razor
I'm trying to build a custom column for an MVCContrib grid, but an getting tripped up by the Razor syntax. Here is my code for building a custom column:
@{Html.Grid(Model).Columns(column =>
{
column.For开发者_JAVA技巧("Data").Do(p => {
<div>@p.Name</div>
});
}).Render();
}
How do you mark the line containing the div so that Razor will treat the line as HTML?
The following should work:
@(Html
.Grid<SomeViewModel>(Model)
.Columns(column => {
column.Custom(@<div>@item.Name</div>).Named("Data");
})
)
This works for me.
@(Html.Grid(Model.PaymentFileLogs)
.AutoGenerateColumns()
.Columns(extraColumns => extraColumns.For(c => "<i class='icon-warning-sign'></i>").Encode(false))
精彩评论