我有一个telerik网格,我想显示如下数据
ProductName Count
Letters 5
Phone
Pens 3
我想做一些事情,如果count> 0,那么只显示count列的e值,即不显示值0.
<% Html.Telerik().Grid(Model.Orders)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.ProductName);
if(Count>0)
{
columns.Bound(o => o.Count);
}
})
.Groupable(settings => settings.Groups(groups => groups.Add(o => o.KeyID)).Visible(false))
.Scrollable(s => s.Enabled(true))
.Scrollable(scrolling => scrolling.Height(300))
.Reorderable(reorder => reorder.Columns(true))
.Footer(true)
.Render();
%>
由于
答案 0 :(得分:3)
您可以使用CellAction渲染条件结果。
<%
Html.Telerik().Grid(Model.Orders)
.Name("Grid")
.CellAction(cell =>
{
if (cell.Column.Title.Equals("Count"))
{
if (cell.DataItem.Count == 0)
{
cell.Text = " ";
}
}
})
.Columns(columns =>
{
columns.Bound(o => o.ProductName);
columns.Bound(o => o.Count);
})
.Groupable(settings => settings.Groups(groups => groups.Add(o => o.KeyID)).Visible(false))
.Scrollable(s => s.Enabled(true))
.Scrollable(scrolling => scrolling.Height(300))
.Reorderable(reorder => reorder.Columns(true))
.Footer(true)
%>