HTML:
<telerik:RadGrid ID="AssignGrid" runat="server" AllowMultiRowSelection="true" AutoGenerateColumns="False"
SkinID="RadGridSkin" OnNeedDataSource="AssignGrid_NeedDataSource">
<ClientSettings>
<Selecting AllowRowSelect="true" />
</ClientSettings>
<MasterTableView DataKeyNames="CATEGORY_ID" GroupsDefaultExpanded="false">
<GroupByExpressions>
<telerik:GridGroupByExpression>
<GroupByFields>
<telerik:GridGroupByField FieldName="CATEGORY_ID" />
</GroupByFields>
<SelectFields>
<telerik:GridGroupByField FieldName="PARTNER_CATEGORY_NAME" />
</SelectFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<GroupHeaderTemplate>
<input type="checkbox" id="chkCategory" class="group_check" runat="server" />
<span style="padding-left: 10px;">Category:
<%# Eval("PARTNER_CATEGORY_NAME")%></span>
<asp:HiddenField ID="Header_cat_id" runat="server" Value='<%#Eval("CATEGORY_ID") %>' />
<asp:HiddenField ID="Header_cat_name" runat="server" Value='<%#Eval("PARTNER_CATEGORY_NAME") %>' />
</GroupHeaderTemplate>
<Columns>
<telerik:GridTemplateColumn HeaderStyle-Width="40px">
<ItemTemplate>
<input type="checkbox" id="CheckRow" class="item_check" runat="server" onclick="SelectCategoryRow(this);" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="PARTNER_CATEGORY_NAME" Display="false" UniqueName="PartnerCatName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="SUB_CATEGORY_ID" Display="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CATEGORY_ID" Display="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PARTNER_SUB_CATEGORY_NAME" HeaderText="Sub-Category Name" UniqueName="PartnerSubCatName">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
服务器端:
AssignGrid_Confirm.DataSource = AssignGrid_dt;
AssignGrid_Confirm.DataBind();
结果:
正在插入一个空项...我该如何删除那些空项?我的最终网格应如下所示:
答案 0 :(得分:0)
两个空行对应于没有sub_category_id的行。您需要在绑定之前从数据源中删除它们,或者您可以在网格控件上设置过滤以隐藏它们。
Telerik's demo page on filtering。我不确定您是否可以设置过滤器,然后不允许用户更改它 - 实际上,您最好从数据源中删除它们,以便从我想到的开始。