Wednesday, 21 October 2015

Here is MVC's WebGrid example





@{
var grid = new WebGrid(
Model, rowsPerPage: 1,
defaultSort: "UserName"
);
}
@grid.GetHtml(
fillEmptyRows: false,
mode: WebGridPagerModes.All,
columns: grid.Columns(
grid.Column("UserID", header: "ID" + MvcPartialView.Models.helpers.SortDirection(null, ref grid, "UserID")),
grid.Column("UserName", header: "Name" + MvcPartialView.Models.helpers.SortDirection(null, ref grid, "UserName")),
grid.Column("Password", header: "Password" + MvcPartialView.Models.helpers.SortDirection(null, ref grid, "Password")),
grid.Column("CreatedDate", header: "Created Date" + MvcPartialView.Models.helpers.SortDirection(null, ref grid, "CreatedDate"), format: (item) => String.Format("{0:dd-MMM-yyyy}", item.CreatedDate))
),
rowStyle:"CssClassName" ,
tableStyle:"",
headerStyle:"",
footerStyle:"" ,
alternatingRowStyle:"",
emptyRowCellValue:"Set any default value to blank column",
selectedRowStyle:"",
displayHeader:true /*defaut is "true". but if don't want to show header then set to false*/
)

No comments:

Post a Comment

Esha Garg