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

how to change the filter row text?

18 Answers 384 Views
GridView
This is a migrated thread and some comments may be shown as answers.
hosein
Top achievements
Rank 1
hosein asked on 02 Dec 2010, 02:27 PM
Hi

I want to change the filter row text but I could not find any way to do that.
I want to show this text: "filter contains: " or any text (even in differnet languages)
and disable the other options of filtering like: "starts with" , "ends with" ,"no filter" and so on.

Is there any way to do that?

thanks

18 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 03:07 PM
Hello,

Yes, you can do this by setting the localization properties and creating a new localization class. Have a look at this documentation  which explains in detail how to do this.
Let me know if you need further help
Richard
0
hosein
Top achievements
Rank 1
answered on 02 Dec 2010, 04:26 PM
thank you for answer
it was very helpful

but how can I remove some options that I don't need?
can you please help about this problem?

thanks again
0
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 04:40 PM

Hello,

You can just remove the ones that you don't need. For exmaple, to be left with just the "Filter Contains" use the following

Public Class MyRadGridLocalizationProvider
    Inherits RadGridLocalizationProvider
    Public Overloads Overrides Function GetLocalizedString(ByVal id As String) As String
        Select Case id
            Case RadGridStringId.FilterFunctionContains
                Return "My Filter Contains"
            Case Else
                Return MyBase.GetLocalizedString(id)
        End Select
    End Function
End Class

Hope that helps
Richard
0
hosein
Top achievements
Rank 1
answered on 02 Dec 2010, 04:58 PM
would you give me the c# code?
Thanks
0
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 05:02 PM
There you go. Hope that helps

public class MyRadGridLocalizationProvider : RadGridLocalizationProvider
{
    public override string GetLocalizedString(string ByValid)
    {
        switch (id) {
            case RadGridStringId.FilterFunctionContains:
                return "My Filter Contains";
                CaseElse();
                return base.GetLocalizedString(id);
        }
    }
}

Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 05:05 PM
Sorry, this should be correct
public class MyRadGridLocalizationProvider : RadGridLocalizationProvider
{
    public override string GetLocalizedString(string ByValid)
    {
        switch (id) {
            case RadGridStringId.FilterFunctionContains:
                return "My Filter Contains";
            default:
                return base.GetLocalizedString(id);
        }
    }
}
0
hosein
Top achievements
Rank 1
answered on 02 Dec 2010, 05:20 PM
thank you for answer
but it does not work!
is there any other problem?

and another question
does the  "CustomFilterDialog" have "right to left" property?
how can I set that property to "right to left"?

thanks again
0
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 05:23 PM
Hello,

To get this working, please refer to my original link. You need to remove all the case statements that you don't need and leave the default one.

Hope that helps
Richard
0
hosein
Top achievements
Rank 1
answered on 02 Dec 2010, 05:31 PM
this is my code
public class CustomLocalizationProvider : RadGridLocalizationProvider
        {
            public override string GetLocalizedString(string id)
            {
                switch (id)
                {
                    case RadGridStringId.AddNewRowString: return "add new row";
                    case RadGridStringId.FilterFunctionContains: return "filter contains";//contains
                    case RadGridStringId.FilterOperatorContains: return "filter contains"; //Operator
                    default:
                        return base.GetLocalizedString(id); 
                }
            }
        }
Is there any problem with my code?
0
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 05:56 PM
This looks fine. The Filter Contains one for exmaple will change the text in the Context Menu from the filter icon.
Richard
0
hosein
Top achievements
Rank 1
answered on 02 Dec 2010, 06:02 PM
that problem was solved several posts ago and I appreciate you for answer

but I want to remove all options except "contains" option

this problem is not solved yet

please help me
thanks
0
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 06:11 PM
Hello,

In this case, you need to add the entire class and return empty strings. For any that you want to put back to the default, just remove the case statement for that line altogether.

Hope that helps
Richard

public class MyGridLocalizationProvider : RadGridLocalizationProvider
{
   public override string GetLocalizedString(string id)
   {
       switch (id)
       {
           case RadGridStringId.FilterFunctionBetween: return "";
           case RadGridStringId.FilterFunctionContains: return "SOMETHING";
           case RadGridStringId.FilterFunctionDoesNotContain: return "";
           case RadGridStringId.FilterFunctionEndsWith: return "";
           case RadGridStringId.FilterFunctionEqualTo: return "";
           case RadGridStringId.FilterFunctionGreaterThan: return "";
           case RadGridStringId.FilterFunctionGreaterThanOrEqualTo: return "";
           case RadGridStringId.FilterFunctionIsEmpty: return "";
           case RadGridStringId.FilterFunctionIsNull: return "";
           case RadGridStringId.FilterFunctionLessThan: return "";
           case RadGridStringId.FilterFunctionLessThanOrEqualTo: return "";
           case RadGridStringId.FilterFunctionNoFilter: return "";
           case RadGridStringId.FilterFunctionNotBetween: return "";
           case RadGridStringId.FilterFunctionNotEqualTo: return "";
           case RadGridStringId.FilterFunctionNotIsEmpty: return "";
           case RadGridStringId.FilterFunctionNotIsNull: return "";
           case RadGridStringId.FilterFunctionStartsWith: return "";
           case RadGridStringId.FilterFunctionCustom: return "";
           case RadGridStringId.CustomFilterMenuItem: return "";
           case RadGridStringId.CustomFilterDialogCaption: return "";
           case RadGridStringId.CustomFilterDialogLabel: return "";
           case RadGridStringId.CustomFilterDialogRbAnd: return "";
           case RadGridStringId.CustomFilterDialogRbOr: return "";
           case RadGridStringId.CustomFilterDialogBtnOk: return "";
           case RadGridStringId.CustomFilterDialogBtnCancel: return "";
           case RadGridStringId.DeleteRowMenuItem: return "";
           case RadGridStringId.SortAscendingMenuItem: return "";
           case RadGridStringId.SortDescendingMenuItem: return "";
           case RadGridStringId.ClearSortingMenuItem: return "";
           case RadGridStringId.ConditionalFormattingMenuItem: return "";
           case RadGridStringId.GroupByThisColumnMenuItem: return "";
           case RadGridStringId.UngroupThisColumn: return "";
           case RadGridStringId.ColumnChooserMenuItem: return "";
           case RadGridStringId.HideMenuItem: return "";
           case RadGridStringId.UnpinMenuItem: return "";
           case RadGridStringId.PinMenuItem: return "";
           case RadGridStringId.BestFitMenuItem: return "";
           case RadGridStringId.PasteMenuItem: return "";
           case RadGridStringId.EditMenuItem: return "";
           case RadGridStringId.CopyMenuItem: return "";
           case RadGridStringId.AddNewRowString: return "";
           case RadGridStringId.ConditionalFormattingCaption: return "";
           case RadGridStringId.ConditionalFormattingLblColumn: return "";
           case RadGridStringId.ConditionalFormattingLblName: return "";
           case RadGridStringId.ConditionalFormattingLblType: return "";
           case RadGridStringId.ConditionalFormattingLblValue1: return "";
           case RadGridStringId.ConditionalFormattingLblValue2: return "";
           case RadGridStringId.ConditionalFormattingGrpConditions: return "";
           case RadGridStringId.ConditionalFormattingGrpProperties: return "";
           case RadGridStringId.ConditionalFormattingChkApplyToRow: return "";
           case RadGridStringId.ConditionalFormattingBtnAdd: return "";
           case RadGridStringId.ConditionalFormattingBtnRemove: return "";
           case RadGridStringId.ConditionalFormattingBtnOK: return "";
           case RadGridStringId.ConditionalFormattingBtnCancel: return "";
           case RadGridStringId.ConditionalFormattingBtnApply: return "";
           case RadGridStringId.ColumnChooserFormCaption: return "";
           case RadGridStringId.ColumnChooserFormMessage: return "";
           default:
               return base.GetLocalizedString(id);
       }
   }
}
0
hosein
Top achievements
Rank 1
answered on 02 Dec 2010, 06:21 PM
This code does not remove the filter options, it just puts an empty string in each for each option

how can I remove them?

beside that problem I want to know how I can have a right to left CustomFilterDialog

Regards
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 06:40 PM
Hello,

This will disable the other filter menu items for you
private void RadGridView1_ContextMenuOpening(System.Object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e)
{
    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("Contains", menuItem.Text)) {
                    menuItem.Enabled = false;
                }
            }
        }
    }
}


I will look into your second question as soon as possible
Richard
0
hosein
Top achievements
Rank 1
answered on 02 Dec 2010, 08:16 PM
It works
Thanks a lot
0
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 08:46 PM
Glad that worked for you.
All the best
Richard
0
shir
Top achievements
Rank 1
answered on 07 Mar 2011, 05:28 PM
hello there
i have written class below:
Public Class tolatin
        Inherits RadGridLocalizationProvider
        Public Overrides Function GetLocalizedString(ByVal id As String) As String
            Return MyBase.GetLocalizedString(id)
            Select Case id
                Case RadGridStringId.FilterFunctionContains
                    Return "consist"
                Case Else
                    Return ""
            End Select
            Return String.Empty
        End Function
    End Class
I also have a grid called RG1. Now where should I write the following code in order to change my grid menu? (in any event?)
RadGridLocalizationProvider.CurrentProvider = New tolatin()
Thanks a lot for your help.
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 07 Mar 2011, 05:48 PM
Helo,

Adding this to the FormLoad should do the job
Hope that helps
Richard
Tags
GridView
Asked by
hosein
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
hosein
Top achievements
Rank 1
shir
Top achievements
Rank 1
Share this question
or