0

私は Telerik グリッドを持っています。以下のようにデータを表示したいです

ProductName Count
Letters     5
Phone   
Pens        3

カウント> 0の場合、カウント列の値のみを表示する、つまり値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();
        %>

ありがとう

4

1 に答える 1

3

CellAction を使用して、条件付きの結果をレンダリングできます。

<%
Html.Telerik().Grid(Model.Orders)
.Name("Grid")
.CellAction(cell => 
  {
    if (cell.Column.Title.Equals("Count"))
    {
      if (cell.DataItem.Count == 0)
      {
        cell.Text = "&nbsp;";
      }
    }
  })
 .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)
%>
于 2012-08-21T13:06:19.037 に答える