Using an asp.net mvc webgrid, is it possible to render a column using Html.DisplayFor for the current row/column?
grid.Column("Roller", "Roller", canSort: true, format: @<text>@Html.DisplayFor( <the row result here> )</text>)
The Html.DisplayFor(m) helper uses the page model, not the current row item. Is there a way around this.
Thanks
// Johan
Yes, it is possible. For an example, consider you are binding a list of
Bannerobjects to your WebGrid. Also consider theBanner.Activeproperty, which is abooleanvalue that you want to be rendered as a CheckBox. You can do this:You could also do this:
But I would consider the first option more readable.