This question is locked. New answers and comments are not allowed.
Hi,
My requirement is to display a customized set of values for a filter rather than usual distinct value for one of the column displayed in a grid.So I handled the event DistinctValuesLoading as below.
private void OnDistinctValuesLoading(object sender, GridViewDistinctValuesLoadingEventArgs e)
{
if(e.column == "Path")
{
e.ItemsSource = list;
}
else
{
e.ItemsSource = this.radGridView.GetDistinctValues(e.Column, true);
}
}
In addition to that I also handled the Filtering event of the grid as mentioned in the code below.
The difference in behavior I found for Path column filter with respect to other columns are:
1. Clear and Filter button click doesn't trigger "Filtering" event.
2. Select All checkbox in the filter doesnot check all the listed values in my filter.
3. Clear button doesn't clear all the checked items in Path column filter
Please help.
Thanks in advance.
My requirement is to display a customized set of values for a filter rather than usual distinct value for one of the column displayed in a grid.So I handled the event DistinctValuesLoading as below.
private void OnDistinctValuesLoading(object sender, GridViewDistinctValuesLoadingEventArgs e)
{
if(e.column == "Path")
{
e.ItemsSource = list;
}
else
{
e.ItemsSource = this.radGridView.GetDistinctValues(e.Column, true);
}
}
In addition to that I also handled the Filtering event of the grid as mentioned in the code below.
The difference in behavior I found for Path column filter with respect to other columns are:
1. Clear and Filter button click doesn't trigger "Filtering" event.
2. Select All checkbox in the filter doesnot check all the listed values in my filter.
3. Clear button doesn't clear all the checked items in Path column filter
Please help.
Thanks in advance.
XML
<telerik:RadGridView Name=
"radGridView"
ItemsSource=
"{Binding Documents}"
CanUserFreezeColumns=
"False"
AutoGenerateColumns=
"False"
ShowGroupPanel=
"False"
RowIndicatorVisibility=
"Collapsed"
DistinctValuesLoading=
"OnDistinctValuesLoading"
Filtering=
"OnFiltering"
>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding Name}"
/>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding Path}"
UniqueName=
"Path"
/>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding Country}"
/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
CS code
List<String> list =
new
List<String>();
private
void
OnDistinctValuesLoading(
object
sender, GridViewDistinctValuesLoadingEventArgs e)
{
if
(e.column ==
"Path"
)
{
e.ItemsSource = list;
}
else
{
e.ItemsSource =
this
.radGridView.GetDistinctValues(e.Column,
true
);
}
}
private
void
OnFiltering(
object
sender, Telerik.Windows.Controls.GridView.GridViewFilteringEventArgs e)
{
foreach
(Telerik.Windows.Data.FilterDescriptor d
in
e.Removed)
{
list.Remove(d.value.ToString()) ;
}
foreach
(Telerik.Windows.Data.FilterDescriptor d
in
e.Added)
{
list.Add(d.value.ToString())
}
}
}