Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Webgrid sample syntax with more options, paging
notes: default paging rows is 10, allow paging and allow sort is default = true. all attributes listed below are optional. a standard generic (auto gen col=true) can be called with a simple @grid.GetHtml()
@grid.GetHtml(
fillEmptyRows: true,
alternatingRowStyle: "alternate-row",
headerStyle: "grid-header",
footerStyle: "grid-footer",
mode: WebGridPagerModes.All,
firstText: "<< First",
previousText: "< Prev",
nextText: "Next >",
lastText: "Last >>",
columns: new [] {
grid.Column( "Name", canSort: false ),
grid.Column( "Surname"),
grid.Column( "EMail",
format: @< a href ="mailto:@item.Email"> @item.Email </a>
),
grid.Column( "BirthDate",
header: "Birth date",
format: p=>p.BirthDate.ToShortDateString()
),
grid.Column( "Children",
header: "Children",
style: "right"
),
grid.Column( "",
header: "Actions",
format: @<text>
@Html.ActionLink("Edit", "Edit", new { id=item.PersonId} )
|
@Html.ActionLink("Delete", "Delete", new { id=item.PersonId} )
</text>
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.