Your partial view with gridview control may look something like this:
@using MyWebApplication.Controllers
@{ var gridHelper = new GridViewHelper();
var grid = Html.DevExpress().GridView(settings =>
{
settings.Name = "MyGridView";
settings.SettingsBehavior.ColumnResizeMode = ColumnResizeMode.Control;
settings.Columns.Add("col1");
settings.Columns.Add("col2");
settings.Columns.Add("col3");
settings.Settings.ShowFooter = true;
settings.HtmlFooterCellPrepared = gridHelper.ShowRowCountInFirstColumn;
});
}@grid.Bind(Model).GetHtml()
And in here is definition of class GridViewHelper
public class GridViewHelper{
public void ShowRowCountInFirstColumn(
object sender,
ASPxGridViewTableFooterCellEventArgs args)
{
if (args.Column.VisibleIndex != 1)
return;
ASPxGridView grid = sender as ASPxGridView;
foreach (ASPxSummaryItem item in grid.TotalSummary)
{
if (item.SummaryType == DevExpress.Data.SummaryItemType.Count)
{
args.Cell.Text = string.Format("{0:n0} rows",grid.GetTotalSummaryValue(item));
return;
}
}
var countSummary = grid.TotalSummary.Add(DevExpress.Data.SummaryItemType.Count, "#");
args.Cell.Text = string.Format("{0:n0} rows",grid.GetTotalSummaryValue(item));
return;
}
}
No comments:
Post a Comment