我有Telerik RadGrid带过滤器菜单我想从过滤器菜单记录中删除一些记录,如IsNull或IsEmpty,我也想更改某些记录的文本..具体我要自定义我的RadGrid过滤器菜单通过C#代码..任何人都可以帮助我吗?
这是我的RadGrid:
<telerik:RadGrid ID="gvErrors" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" CellSpacing="0" GridLines="None" ShowGroupPanel="True">
<ClientSettings allowdragtogroup="True">
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView AutoGenerateColumns="False" DataKeyNames="TicketID">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="TicketID" DataType="System.Decimal"
FilterControlAltText="Filter TicketID column" HeaderText="TicketID"
Visible="false" ReadOnly="True" SortExpression="TicketID" UniqueName="TicketID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="user_name" FilterControlAltText="Filter user_name column" HeaderText="UserName" SortExpression="user_name" UniqueName="user_name">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="email" FilterControlAltText="Filter email column" HeaderText="email" SortExpression="email" UniqueName="email">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Category" FilterControlAltText="Filter Category column" HeaderText="Category" SortExpression="Category" UniqueName="Category">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Title" FilterControlAltText="Filter Title column" HeaderText="Title" SortExpression="Title" UniqueName="Title">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Issue" FilterControlAltText="Filter Issue column" HeaderText="Issue" SortExpression="Issue" UniqueName="Issue">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="TicketDate" DataType="System.DateTime" FilterControlAltText="Filter TicketDate column" HeaderText="TicketDate" SortExpression="TicketDate" UniqueName="TicketDate">
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn DataField="TicketTime" DataType="System.TimeSpan" FilterControlAltText="Filter TicketTime column" HeaderText="TicketTime" SortExpression="TicketTime" UniqueName="TicketTime">
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
答案 0 :(得分:1)
请尝试使用以下代码段。
public void Page_Load(object sender, EventArgs e)
{
GridFilterMenu menu = RadGrid1.FilterMenu;
int i = 0;
while (i < menu.Items.Count)
{
if (menu.Items[i].Text == "IsNull")
{
//Upadte Text
menu.Items[i].Text = "your_custom_string";
}
else if (menu.Items[i].Text == "IsEmpty")
{
//Rmeove menu item
menu.Items.RemoveAt(i);
}
i++;
}
}