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

Localization - Group Panel Elements

1 Answer 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Joel asked on 13 Oct 2011, 09:43 PM

Hi telerik ppl:

Im using this code to swap languages for the column headers and also for the grouping fields labels within the group panel.
 

protected void RadGrid1_ItemCreated(object sender,GridItemEventArgs e){
            if (e.Item is GridHeaderItem)
            {
                string strControl = "";
                GridHeaderItem headerItem = e.Item as GridHeaderItem;
                headerItem["IDColumn"].Text = GetResource("Document ID");
                headerItem["companyColumn"].Text = GetResource("Company");
                headerItem["nameColumn"].Text = GetResource("Name, First");
                headerItem["dueDateColumn"].Text = UBGlobal.GetResource("Due Date");
                headerItem["ageColumn"].Text = GetResource("Age");
                headerItem["assignedToColumn"].Text = GetResource("Assigned To");
                headerItem["activityTypeCodeColumn"].Text = GetResource("Next Activity");
                headerItem["subjectColumn"].Text = GetResource("Last Activity Notes");
                headerItem["phoneColumn"].Text = GetResource("Phone");
                 
            }
 
 
            if (RadGrid1.GroupPanel.GroupPanelItems.Count > 0)
            {
                RadGrid1.GroupPanel.GroupPanelItems.Count.ToString());
                for (int i = 0; i < RadGrid1.GroupPanel.GroupPanelItems.Count; i++)
                {
                    RadGrid1.GroupPanel.GroupPanelItems[i].Text = GetResource(RadGrid1.GroupPanel.GroupPanelItems[i].Text);
                }
            }           
}

 
The problem here is that the objects within the Group Panel are not being translated when loading the grid or after draging and drop a column into the group panel.......the traslations are only being done when colapsing or expanding the grid rows.

I think this is because the Group Panel doesnt have elements when the ItemCreated Event is fired.....so my questions are:

1.- When is the Group Panel being populated.
and/or
2.- is there a better way to localize the Group Panel elements.......

This must be done in CODEBEHIND.....srry about the caps, are only to emphasize the fact that I cant use the fieldAlias property due to the fact that 3 different language translations must be done and the texts are changed so oftenly.

Thks in advance

1 Answer, 1 is accepted

Sort by
0
Joel
Top achievements
Rank 1
answered on 14 Oct 2011, 05:00 PM
Ok I figured out how to do it.

This code made the trick
 
protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            GridGroupPanel panel = (GridGroupPanel)RadGrid1.GroupPanel;
            if (panel.GroupPanelItems.Count > 0)
            {
                for (int i = 0; i < panel.GroupPanelItems.Count; i++)
                {
                    Literal literal = (Literal)panel.GroupPanelItems[i].Controls[0];
 
 
            //HTML space is always being added at the end of the text string use "" to enclose the &nbsp;                   
                    switch (literal.Text.Replace(&nbsp;,""))
                    {
                        case "Document":
                            literal.Text = GetResource("Document");
                            break;
                        case "Company":
                            literal.Text = GetResource("Company");
                            break;
                        case "Name, First":
                            literal.Text = GetResource("Name, First");
                            break;
                        case "Due Date":
                            literal.Text = GetResource("Due Date");
                            break;
                        case "Age":
                            literal.Text = GetResource("Age");
                            break;
                        case "Assigned To":
                            literal.Text = GetResource("Assigned To");
                            break;
                        case "Next Activity":
                            literal.Text = GetResource("Next Activity");
                            break;
                        case "Last Activity Notes":
                            literal.Text = GetResource("Last Activity Notes");
                            break;
                        case "Phone":
                            literal.Text = GetResource("Phone");
                            break;
                    }
                     
                }
 
            }
             
        }


Regards!!!
Tags
Grid
Asked by
Joel
Top achievements
Rank 1
Answers by
Joel
Top achievements
Rank 1
Share this question
or