Afternoon,
I'm having a small issue getting my code to function properly and wondered if someone could let me know where I'm going wrong.
Within my project are a couple of columns which hold dates. What I am trying to do is remove the "Is null" and "Is not null" options from the filter list for those columns.
Having searched the forums and read through some of the documentation I have come up with the below code.
This works perfectly fine if I right click on the filter button for either of those columns. However, if I left click it doesn't correctly register the column FieldName. Instead it will report the FieldName of the column which has an entry selected within the GridView (Example would be that I have a company name selected with the grid view, left click the filter button for the next call date and it will think that the FieldName is CompanyName instead).
Am I doing it completely wrong or am I just missing something?
Regards,
Guy
I'm having a small issue getting my code to function properly and wondered if someone could let me know where I'm going wrong.
Within my project are a couple of columns which hold dates. What I am trying to do is remove the "Is null" and "Is not null" options from the filter list for those columns.
Having searched the forums and read through some of the documentation I have come up with the below code.
private
void
radGridView1_ContextMenuOpening(
object
sender, ContextMenuOpeningEventArgs e)
{
if
(
this
.radGridView1.CurrentCell
is
GridDataCellElement ||
this
.radGridView1.CurrentCell
is
GridFilterCellElement && e.ContextMenuProvider ==
null
)
{
if
(((GridViewDataColumn)
this
.radGridView1.CurrentColumn).FieldName ==
"DateCalled"
||
((GridViewDataColumn)
this
.radGridView1.CurrentColumn).FieldName ==
"NextCallDate"
)
{
if
(e.ContextMenu.Items.Count > 0)
{
if
(e.ContextMenu.Items[0]
is
Telerik.WinControls.UI.RadFilterOperationMenuItem)
{
foreach
(Telerik.WinControls.UI.RadMenuItemBase menuItem
in
e.ContextMenu.Items)
{
if
(
string
.Equals(
"Is null"
, menuItem.Text) ||
string
.Equals(
"Is not null"
, menuItem.Text))
{
menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
}
}
}
}
}
}
}
This works perfectly fine if I right click on the filter button for either of those columns. However, if I left click it doesn't correctly register the column FieldName. Instead it will report the FieldName of the column which has an entry selected within the GridView (Example would be that I have a company name selected with the grid view, left click the filter button for the next call date and it will think that the FieldName is CompanyName instead).
Am I doing it completely wrong or am I just missing something?
Regards,
Guy