Hi
I want to customise the available filter operators and change the default operator in my RadGridView
For example in a string column, I'd like to default to 'Starts With' instead of 'Contains' and want to remove the 'Ends With' operator.
Thanks
Tung
4 Answers, 1 is accepted
Thank you for writing.
The default filters are determined according to the type of the column. In order to change the default one you would add an empty filter descriptor having the required operator:
radGridView1.Columns[0].FilterDescriptor =
new
Telerik.WinControls.Data.FilterDescriptor(
null
, Telerik.WinControls.Data.FilterOperator.StartsWith,
null
);
Regarding your other question, you can handle the ContextMenuOpening event of the grid and remove the Ends with menu item:
private
void
radGridView1_ContextMenuOpening(
object
sender, ContextMenuOpeningEventArgs e)
{
RadMenuItem item = e.ContextMenu.Items.Where(i => i.Text ==
"Ends with"
).FirstOrDefault()
as
RadMenuItem;
if
(item !=
null
)
{
e.ContextMenu.Items.Remove(item);
}
}
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo
Telerik by Progress
Hi Hrist
I managed to remove the filter operators but I'm having issues with changing the filter operator.
I can create the filter descriptor with a StartsWith operator then I tried to set it as the FilterDescriptor for radGridView1:MasterTemplate.Columns['field'] then radGridView1:Columns['field'] like your example but I get an error message about chained attribute expression.
I have four columns I want to change but it changes only three of them and the operator doesn't change from Contains to Starts With until I put the mouse cursor over the grid.
I'm using Progress Openedge so I don't know if that might be a factor.
Thanks
Tung
Hi Hristo
Ignore my last post. I had methods for the FilterChanged and FilterChanging events to handle batching ourselves and they were interferring with your code example.
I unsubscribe those events while I set the empty filter and resubscribe afterwards and it works fine now.
Thanks for your help
Tung
Thank you for the update.
As I understand currently you have the issue resolved.
Should you have further questions do not hesitate to write back.
Regards,
Hristo
Telerik by Progress