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

Filter translation and items removal, RadMenu Filter

3 Answers 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ino
Top achievements
Rank 1
Ino asked on 29 Jan 2014, 07:30 PM
I had a hard time to find a solution to RadMenu filter in RadGrid and made the code myself so i wanted to share it if anyone else needed it.
Maybe someone could point out stuff i could have done better... i used it here to translate to danish...

protected override void OnLoad(EventArgs e)
{
   gridview2.HeaderContextMenu.ItemCreated += HeaderContextMenu_ItemCreated;
    base.OnLoad(e);
}
 
protected void HeaderContextMenu_ItemCreated(object sender, RadMenuEventArgs e)
{
    switch (e.Item.Value)
    {
        case "SortAsc":
            e.Item.Text = "Sortere ascending";
            break;
        case "SortDesc":
            e.Item.Text = "Sortere descending";
            break;
        case "SortNone":
            e.Item.Text = "Fjern sortering";
            break;
        case "GroupBy":
            e.Item.Remove();
            break;
        case "UnGroupBy":
            e.Item.Remove();
            break;
        case "ColumnsContainer":
            e.Item.Text = "Vis/Fjern Kolonner";
            break;
        case "FilterMenuParent":
            e.Item.Text = "Filter";
            break;
        case "FilterMenuContainer":
            var btnClearFilter = e.Item.FindControl("HCFMClearFilterButton") as Button;
 
            var lcShowRows = e.Item.Controls[1] as LiteralControl;
            var lcAnd = e.Item.Controls[4] as LiteralControl;
            var btnFilter = e.Item.FindControl("HCFMFilterButton") as Button;
 
            if (btnClearFilter != null) btnClearFilter.Text = "Fjern filter";
            if (lcShowRows != null) lcShowRows.Text = "<label class=\"rgHCMShow\">Vis rækker der følger disse regler:</label>";
            if (lcAnd != null) lcAnd.Text = "<label class=\"rgHCMAnd\">Og</label>";
            if (btnFilter != null) btnFilter.Text = "Tilføj filters";
 
            foreach (var combo in e.Item.Controls.OfType<RadComboBox>())
            {
                var i = 0;
                while (i < combo.Items.Count)
                {
                    switch (combo.Items[i].Text)
                    {
                        case "NoFilter":
                            combo.Items[i].Text = "Intet Filter";
                            i++;
                            break;
                        case "Contains":
                            combo.Items[i].Text = "Indeholder";
                            i++;
                            break;
                        case "EqualTo":
                            combo.Items[i].Text = "Er Lig Med";
                            i++;
                            break;
                        case "GreaterThan":
                            combo.Items[i].Text = "Større End";
                            i++;
                            break;
                        case "LessThan":
                            combo.Items[i].Text = "Mindre End";
                            i++;
                            break;
                        default:
                            combo.Items.Remove(i);
                            break;
                    }
                }
            }
            break;
    }
}

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 03 Feb 2014, 05:48 PM
Hi Ino,

A help article that demonstrates how to localize the filtering menu options in radgrid is available here:
http://www.telerik.com/help/aspnet-ajax/grid-localizing-filtering-menu-options.html

Regards,
Pavlina
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Ino
Top achievements
Rank 1
answered on 04 Feb 2014, 11:13 AM
Didnt get that one to Work for the builtin Context Radmenu for Radgrid... it only Works if i use the row with filters inside grid
0
Accepted
Pavlina
Telerik team
answered on 07 Feb 2014, 11:56 AM
Hi Ino,

Indeed you are right and the article I sent you demonstrates how to localize the basic filtering options only. The approach you implement to translate context menu items is correct and it could be used by anyone else.

However, the most convenient way would be to use global resource files:
Localization through global resources
RadGrid Localization demo

Regards,
Pavlina
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Ino
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Ino
Top achievements
Rank 1
Share this question
or