This is a migrated thread and some comments may be shown as answers.

Change displayed text for distinct filters

6 Answers 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
haagel
Top achievements
Rank 1
haagel asked on 16 Jun 2011, 10:41 AM

Is it possible to change the text of the checkboxes that are shown for the distinct filters in the filter popup?

 

I have a RadGridView where one of the column is of type nullable bool. I have a cell edit template for this column with a RadComboBox that has two options, 'Yes' and 'No', that of course corresponds to True and False. Also I have set ClearSelectionButtonVisibility="Visible" on the RadComboBox so that the user can set the value to null. This works fine.

 

My problem is that in the filter popup of the column I have dinstict filters with the three available options true, false and null. This also works fine BUT the text of the checkboxes show 'True', 'False' and '' (empty string) respectively. I would like them to show the same as in my ComboBox, that is 'Yes' and 'No' instead.

 

Is this possible to accomplish, and in that case how?

6 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 16 Jun 2011, 11:34 AM
Hi haagel,

You can use an IValueConverter on the column DataMemberBinding. It will be respected by the distinct values.

Best wishes,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
haagel
Top achievements
Rank 1
answered on 16 Jun 2011, 03:12 PM
Great!

Thanks Ross! :)
0
Martin
Top achievements
Rank 1
Veteran
answered on 26 Jun 2020, 08:32 AM
I have a similar problem for my RadGridView, but don't really understand how to fix it. Could you maybe provide an example?
0
Martin
Top achievements
Rank 1
Veteran
answered on 26 Jun 2020, 09:16 AM

I have the following column:

                <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" />

 

Where the converter converts a bool to a string. But my column filter still displays "True" and "False". What am I doing wrong?

0
Dinko
Telerik team
answered on 30 Jun 2020, 01:45 PM

Hello Martin,

Thank you for the provided code snippet.

Instead of using IValueConverter, I would suggest creating an additional property that returns the string representation of the ReminderPassed property.

private bool reminderPassed;
public bool ReminderPassed
{
    get { return reminderPassed; }
    set { reminderPassed = value; this.OnPropertyChanged("ReminderPassed"); }
}

public string ReminderPassed_String
{
    get
    {
        return ReminderPassed.ToString();
    }
}

<telerik:GridViewDataColumn
    DataMemberBinding="{Binding ReminderPassed_String}"
    x:Name="ReminderIcon"
    CellStyle="{StaticResource IncidentListTextEffects}"
    Header=""
    IsReadOnly="True"
    IsVisible="{Binding IsTemplateList, Converter={StaticResource InvertBoolConverter}}"
    SortMemberPath="RemindAtLocal" />

This way, you will be able to filter the string representation of the ReminderPassed property.

Regards,
Dinko
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Martin
Top achievements
Rank 1
Veteran
answered on 01 Jul 2020, 08:19 AM
Thanks, it worked!
Tags
GridView
Asked by
haagel
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
haagel
Top achievements
Rank 1
Martin
Top achievements
Rank 1
Veteran
Dinko
Telerik team
Share this question
or