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("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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With