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

[Solved] GroupByExpression field alias localization

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
slam
Top achievements
Rank 1
slam asked on 09 Jun 2009, 12:51 PM

When setting the GroupByExpression property for a template column I would like to declaratively assign the field alias to a resource so that it is localized.
My current expression is: 

 

 

<telerik:GridTemplateColumn   
    GroupByExpression="FieldName AliasName Group By FieldName asc"   
 

 

 

How can I replace 'AliasName' so that it uses <%$ Resources:Grid, AliasName%> ?

I don't want an initial grouping state so have not set the GroupByExpressions property for the MasterTableView.

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 15 Jun 2009, 11:15 AM
Hello Slam,

You can use the ResourceManager and set the AliasName resource string in code-behind or use the same declarative approach (using predefined groups).

ResourceManager Class (System.Resources)


Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
slam
Top achievements
Rank 1
answered on 15 Jun 2009, 12:41 PM
Hi Daniel,
Thanks for your reply.
My current (successful) approach for localizing the group field alias is in the code behind - handling the Groups Changing event and using the resource manager to set the alias name. However I was hoping to avoid doing this by declaratively setting the alias in the aspx file. Also, I do not want a predefined grouping on my page. I want the user to determine when the group is displayed.
Am I correct in using the Groups Changing event, as shown below, or is there a better approach?
Thanks.

protected void Grid_GroupsChanging(object source, GridGroupsChangingEventArgs e)  
{  
    if (e.Action == GridGroupsChangingAction.Group)  
    {  
        if (e.Expression.SelectFields[0].FieldName == "Name")  
        {  
            e.Expression.SelectFields[0].FieldAlias = Resources.Grid.AliasName;  
        }  
    }  

 

0
Accepted
Daniel
Telerik team
answered on 18 Jun 2009, 11:34 AM
Hello Slam,

My opinion is that your approach is excellent. Unfortunately it is not possible to localize the field alias declaratively. I believe you already found the best way to achieve the desired functionality.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
slam
Top achievements
Rank 1
Answers by
Daniel
Telerik team
slam
Top achievements
Rank 1
Share this question
or