I want to create custom filter properties for my column in the RadGridView, similar to the example given here: https://docs.telerik.com/devtools/winforms/controls/gridview/filtering/excel-like-filtering#customizing-excel-like-filtering-popup
What I have is a column with bool values that are converted to icons. I want to create a column filter where I have custom provided names for the properties which represents the bool values. According to this: https://docs.telerik.com/devtools/wpf/controls/radgridview/filtering/how-to/howto-customize-the-default-field-filter-editor a plain TextBox will be shown for a bool column, but I would like to show a StringFilterEditor with my own values for true and false. I would prefer to do this without creating a custom template.
Is this possible?
Thanks in advance
4 Answers, 1 is accepted
Hello Martin,
The mentioned StringFilterEditor control is shown when RadGridView's FilteringMode is FilterRow. Do you use this setting? I am asking because that are two completely different modes and I need to be sure which one you are using.
It will be great if you can share more information about the desired result.
Regards,
Yoan
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
This is how the column that I have is defined:
<telerik:GridViewDataColumn
DataMemberBinding="{Binding ReminderPassed, Mode=OneWay, Converter={StaticResource BoolToColumnFilterTextConverter}}"
x:Name="ReminderIcon"
CellStyle="{StaticResource IncidentListTextEffects}"
Header=""
FilterMemberPath="ReminderPassed"
IsReadOnly="True"
IsVisible="{Binding IsTemplateList, Converter={StaticResource InvertBoolConverter}}"
SortMemberPath="RemindAtLocal">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="2,0"
Padding="0"
FontFamily="{StaticResource TelerikWebUI}"
Text="{StaticResource GlyphWarning}">
<TextBlock.Visibility>
<MultiBinding>
<MultiBinding.Converter>
<valueConverters:CompareDateTimeToVisibilityConverter />
</MultiBinding.Converter>
<Binding Mode="OneWay" Path="RemindAtLocal" />
<Binding
Mode="OneWay"
Path="Now"
Source="{StaticResource DateTimeNowTicker}" />
</MultiBinding>
</TextBlock.Visibility>
</TextBlock>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
It is bound to a bool value which is converted to a string. This solved the problem of showing the StringFilterEditor. Now the problem is that the filter values are "True" and "False" instead of what the converter is returning (see the attached file for a visual of how it looks).
And here is my converter:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace NTS.Client.Features.Incidents.ValueConverters
{
class BoolToColumnFilterTextConverter : IValueConverter
{
/// <summary>
/// This converter is used for the filtering of the ReminderIcon column in the incident list
/// It is needed to display the correct names for the checkboxes in the filter list
/// </summary>
/// <param name="values"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public object Convert(object obj, Type targetType, object parameter, CultureInfo culture)
{
bool reminderPassed = (bool)obj;
if(obj == null || reminderPassed)
{
return "PÃ¥minnelsetid passerad";
}
else
{
return "PÃ¥minnelsetid inte passerad";
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
I want the strings returned by the converter to show up in the column filter. How do I do that?
Thanks :)
Hi Martin,
Thank you for the update. I am glad to hear this.
If you have further questions, do not hesitate to contact us again.
Regards,
Yoan
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.