[PROBLEM] Telerik RadGridView and shifted columns.

1 Answer 22 Views
GridView
Bexel Consulting
Top achievements
Rank 1
Iron
Bexel Consulting asked on 03 Mar 2022, 11:00 AM

Hi!


I think we have a problem with Telerik RadGridView.



We are using RadGridView with several columns (GridViewTextBoxColumn and GridViewDecimalColumn).

Every column has a concrete header text which is localized.
Every time we have tried adding a new column somewhere in the middle of the collection, Telerik RadGridView shifts all the columns that follow the inserted column by one place. It means that we have to change the translation for those shifted columns after each addition, and it is very frustrating and sometimes our translation was messed up. The same situation is with removing columns.


Do you have any knowledge about the described behavior?
Do you know how can I avoid shifting columns, and thus changing the translation?


Thank you for the answer in advance!

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Mar 2022, 11:57 AM

Hello, Veljko,

RadGridView offers the following approach for localizing the columns' HeaderText:

1. Add a RadGridView with columns.
2. Select the form and in the Properties window, set the form's Localizable property to true.
3. Specify the column's HeaderText for the default language, e.g. "en-US".
4. Set the form's Language property to French (Belgium).
5. Specify the column's HeaderText for  French (Belgium).
6. Set the CurrentUICulture before the InitializeComponent method to "fr-BE". If you run the application, the column is localized as expected.

    public partial class RadForm1 : Telerik.WinControls.UI.RadForm
    {
        public RadForm1()
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-BE");
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            InitializeComponent();
        }
    }

Note that this approach generates resource files for each language storing the different translations:

When the Columns collection is updated in any way, e.g. a new column is added, note that the columns may be regenerated, e.g. from variable gridViewTextBoxColumn1 and gridViewTextBoxColumn2, they can become gridViewTextBoxColumn3 and gridViewTextBoxColumn4. This is possible to mess up the resource files with the translations as well.

The possible solution that I can suggests is to construct the whole grid first and add all the columns you need. Then, start translating the columns' headers. 

A better and recommended option is to perform the whole columns translation at run time considering the CurrentUICulture. Just iterate the columns and specify the respective HeaderText according to the current language.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
Bexel Consulting
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or