这是我的 webgrid。我正在尝试添加一个显示计算值的列“EndDate”
var grid = new WebGrid(canPage: true, rowsPerPage: Model.PageSize, canSort: true, ajaxUpdateContainerId: "grid");
grid.Bind(Model.MyRecords, rowCount: Model.TotalRecords, autoSortAndPage: false);
grid.Pager(WebGridPagerModes.All);
@grid.GetHtml(htmlAttributes: new { id = "grid" },
columns: grid.Columns(
grid.Column("StartDate", "Live Date"),
grid.Column("EndOffsetSeconds", "End in Seconds"),
grid.Column("StartDate"+TimeSpan.FromSeconds("OffsetSeconds"), "Difference"),
grid.Column(header: "Action", format: (item) => Html.ActionLink("Edit", "Edit", new { id = item.ID })),
grid.Column(format: (item) => Html.ActionLink("Copy", "CopyRecord", new { id = item.ID }))
));
我想显示 EndDate 代替第三列。
Enddate = StartDate+TimeSpan.FromSeconds(EndOffsetSeconds)
在第三列我想显示 StartDate+TimeSpan.FromSeconds(EndOffsetSeconds) 的结果
其中 StartDate 是 DateTime 类型, EndOffsetSeconds 是 Integer 类型
示例 DateTime StartDate =05/20/2012 12:15:03 int EndOffsetSeconds=124000;
如何使用 Webgrid 添加计算列?
先感谢您