Globalization in ASP.NET MVC Tree Grid control

21 Jul 202324 minutes to read

Localization

The Localization library allows you to localize default text content of the TreeGrid. The treegrid component has static text on some features (like toolbar area text, filter menu text, pager information text, etc.) that can be changed to other cultures (Arabic, Deutsch, French, etc.) by defining the Locale value and translation object.

The following list of properties and its values are used in the treegrid.

Locale keywords Text
EmptyRecord No records to display
True true
False false
ExpandAll Expand All
CollapseAll Collapse All
RowIndent Indent
RowOutdent Outdent
InvalidFilterMessage Invalid Filter Data
FilterbarTitle \s filter bar cell
Add Add
Edit Edit
Cancel Cancel
Update Update
Delete Delete
Print Print
Pdfexport PDF Export
Excelexport Excel Export
Wordexport Word Export
Csvexport CSV Export
Search Search
Save Save
EditOperationAlert No records selected for edit operation
DeleteOperationAlert No records selected for delete operation
SaveButton Save
OKButton OK
CancelButton Cancel
EditFormTitle Details of
AddFormTitle Add New Record
ConfirmDelete Are you sure you want to Delete Record?
SearchColumns search columns
Matchs No Matches Found
FilterButton Filter
ClearButton Clear
StartsWith Starts With
EndsWith Ends With
Contains Contains
Equal Equal
NotEqual Not Equal
LessThan Less Than
LessThanOrEqual Less Than Or Equal
GreaterThan Greater Than
GreaterThanOrEqual Greater Than Or Equal
ChooseDate Choose a Date
EnterValue Enter the value
autoFitAll Auto Fit all columns
autoFit Auto Fit this column
Export Export
FirstPage First Page
LastPage Last Page
PreviousPage Previous Page
NextPage Next Page
SortAscending Sort Ascending
SortDescending Sort Descending
EditRecord Edit Record
DeleteRecord Delete Record
Above Above
Below Below
AddRow Add Row
FilterMenu Filter
SelectAll Select All
Blanks Blanks
FilterTrue True
FilterFalse False
NoResult No Matches Found
ClearFilter Clear Filter
NumberFilter Number Filters
TextFilter Text Filters
DateFilter Date Filters
MatchCase Match Case
Between Between
CustomFilter Custom Filter
CustomFilterPlaceHolder Enter the value
CustomFilterDatePlaceHolder Choose a date
AND AND
OR OR
ShowRowsWhere Show rows where:
currentPageInfo {0} of {1} pages
totalItemsInfo ({0} items)
firstPageTooltip Go to first page
lastPageTooltip Go to last page
nextPageTooltip Go to next page
previousPageTooltip Go to previous page
nextPagerTooltip Go to next pager items
previousPagerTooltip Go to previous pager items
pagerDropDown Items per page
pagerAllDropDown Items
All All

Loading translations

To load translation object in an application, use load function of the L10n class.

The following example demonstrates the TreeGrid in Deutsch culture.

@using Syncfusion.EJ2.Grids

@(Html.EJS().TreeGrid("TreeGrid").DataSource((IEnumerable<object>)ViewBag.datasource)
      .AllowFiltering()
      .AllowPaging()
      .PageSettings(page => page.PageSize(7))
      .FilterSettings(filter =>
       {
         filter.Type(Syncfusion.EJ2.TreeGrid.FilterType.Menu);
       })
       .Columns(col =>
        {
          col.Field("TaskId").HeaderText("Task ID").Width(90).TextAlign(TextAlign.Right).Add();
          col.Field("TaskName").HeaderText("Task Name").Width(180).Add();
          col.Field("Duration").HeaderText("Duration").Width(80).TextAlign(TextAlign.Right).Add();

        }).Height(220).ChildMapping("Children").Toolbar(new List<string>() { "Print" })
          .Locale("de-DE").TreeColumnIndex(1).Render()
)

<script>
    ej.base.L10n.load({
        'de-DE': {
            'treegrid': {
                'EmptyRecord': 'Keine Aufzeichnungen angezeigt',
                'Expand All': 'Alle erweitern',
                'Collapse All': 'Alles einklappen',
                "Print": "Drucken",
                "Pdfexport": "PDF-Export",
                "Excelexport": "Excel-Export",
                "Wordexport": "Word-Export",
                "FilterButton": "Filter",
                "ClearButton": "klar",
                "StartsWith": "Beginnt mit",
                "EndsWith": "Endet mit",
                "Contains": "Enthält",
                "Equal": "Gleich",
                "NotEqual": "Nicht gleich",
                "LessThan": "Weniger als",
                "LessThanOrEqual": "Weniger als oder gleich",
                "GreaterThan": "Größer als",
                "GreaterThanOrEqual": "Größer als oder gleich",
                "EnterValue": "Geben Sie den Wert ein",
                "FilterMenu": "Filter"
            },
            'pager': {
                'currentPageInfo': '{0} von {1} Seiten',
                'totalItemsInfo': '({0} Beiträge)',
                'firstPageTooltip': 'Zur ersten Seite',
                'lastPageTooltip': 'Zur letzten Seite',
                'nextPageTooltip': 'Zur nächsten Seite',
                'previousPageTooltip': 'Zurück zur letzten Seit',
                'nextPagerTooltip': 'Gehen Sie zu den nächsten Pager-Elementen',
                'previousPagerTooltip': 'Gehen Sie zu vorherigen Pager-Elementen'
            },
            "dropdowns": {
                "noRecordsTemplate": "Keine Aufzeichnungen gefunden"
            },
            "datepicker": {
                "placeholder": "Wählen Sie ein Datum",
                "today": "heute"
            }
        }
    });
</script>
public IActionResult Index()
{
    var tree = TreeData.GetDefaultData();
    ViewBag.datasource = tree;
    return View();
}

Internationalization

The Internationalization library is used to globalize number, date, and time values in treegrid component using format strings in the Format property of Column.

@using Syncfusion.EJ2.Grids

@(Html.EJS().TreeGrid("TreeGrid").DataSource((IEnumerable<object>)ViewBag.datasource)
      .AllowFiltering()
      .AllowPaging()
      .PageSettings(page => page.PageSize(7))
      .FilterSettings(filter =>
       {
          filter.Type(Syncfusion.EJ2.TreeGrid.FilterType.Menu);
       })
       .Columns(col =>
        {
          col.Field("orderID").HeaderText("Order ID").Width(90).TextAlign(TextAlign.Right).Add();
          col.Field("orderName").HeaderText("Order Name").Width(180).Add();
          col.Field("price").HeaderText("Price").Width(80).Format("C2").Type("number").TextAlign(TextAlign.Right).Add();

        }).Height(220).ChildMapping("subTasks").Toolbar(new List<string>() { "Print" })
          .Locale("de-DE").TreeColumnIndex(1).Render()
)

<script>
    ej.base.setCurrencyCode('EUR');
    ej.base.L10n.load({
        'de-DE': {
            'treegrid': {
                'EmptyRecord': 'Keine Aufzeichnungen angezeigt',
                'Expand All': 'Alle erweitern',
                'Collapse All': 'Alles einklappen',
                "Print": "Drucken",
                "Pdfexport": "PDF-Export",
                "Excelexport": "Excel-Export",
                "Wordexport": "Word-Export",
                "FilterButton": "Filter",
                "ClearButton": "klar",
                "StartsWith": "Beginnt mit",
                "EndsWith": "Endet mit",
                "Contains": "Enthält",
                "Equal": "Gleich",
                "NotEqual": "Nicht gleich",
                "LessThan": "Weniger als",
                "LessThanOrEqual": "Weniger als oder gleich",
                "GreaterThan": "Größer als",
                "GreaterThanOrEqual": "Größer als oder gleich",
                "EnterValue": "Geben Sie den Wert ein",
                "FilterMenu": "Filter"
            },
            'pager': {
                'currentPageInfo': '{0} von {1} Seiten',
                'totalItemsInfo': '({0} Beiträge)',
                'firstPageTooltip': 'Zur ersten Seite',
                'lastPageTooltip': 'Zur letzten Seite',
                'nextPageTooltip': 'Zur nächsten Seite',
                'previousPageTooltip': 'Zurück zur letzten Seit',
                'nextPagerTooltip': 'Gehen Sie zu den nächsten Pager-Elementen',
                'previousPagerTooltip': 'Gehen Sie zu vorherigen Pager-Elementen'
            },
            "dropdowns": {
                "noRecordsTemplate": "Keine Aufzeichnungen gefunden"
            },
            "datepicker": {
                "placeholder": "Wählen Sie ein Datum",
                "today": "heute"
            }
        }
    });
</script>
public IActionResult Index()
{
    var tree = TreeDataFormat.GetDataFormat();
    ViewBag.datasource = tree;
    return View();
}

NOTE

In the above sample, Price column is formatted by NumberFormatOptions.

By default, Locale value is en-US. If you want to change the en-US culture to a different culture, you have to change the Locale accordingly.

Right to left (RTL)

RTL provides an option to switch the text direction and layout of the TreeGrid component from right to left. It improves the user experiences and accessibility for users who use right-to-left languages (Arabic, Farsi, Urdu, etc.). To enable RTL Grid, set the EnableRtl to true.

@using Syncfusion.EJ2.Grids

@(Html.EJS().TreeGrid("TreeGrid").DataSource((IEnumerable<object>)ViewBag.datasource)
      .AllowFiltering()
      .AllowPaging()
      .PageSettings(page => page.PageSize(7))
      .FilterSettings(filter =>
       {
          filter.Type(Syncfusion.EJ2.TreeGrid.FilterType.Menu);
       })
       .Columns(col =>
        {
          col.Field("TaskId").HeaderText("Task ID").Width(90).TextAlign(TextAlign.Right).Add();
          col.Field("TaskName").HeaderText("Task Name").Width(180).Add();
          col.Field("Duration").HeaderText("Duration").Width(80).TextAlign(TextAlign.Right).Add();

        }).Height(220).ChildMapping("Children").Toolbar(new List<string>() { "Print" })
          .Locale("ar-AE").EnableRtl(true).TreeColumnIndex(1).Render()
)

<script>
    ej.base.L10n.load({
        'ar-AE': {
            'treegrid': {
                "EmptyRecord": "لا سجلات لعرضها",
                "Print": "طباعة",
                "FilterButton": "منقي",
                "ClearButton": "واضح",
                "StartsWith": "ابدا ب",
                "EndsWith": "ينتهي مع",
                "Contains": "يحتوي على",
                "Equal": "مساو",
                "NotEqual": "غير متساوي",
                "LessThan": "أقل من",
                "LessThanOrEqual": "اصغر من او يساوي",
                "GreaterThan": "أكثر من",
                "GreaterThanOrEqual": "أكبر من أو يساوي",
                "ChooseDate": "اختر تاريخا",
                "EnterValue": "أدخل القيمة",
                "FilterMenu": "منقي"
            },
            'pager': {
                'currentPageInfo': '{0} من {1} صفحة',
                'totalItemsInfo': '({0} العناصر)',
                'firstPageTooltip': 'انتقل إلى الصفحة الأولى',
                'lastPageTooltip': 'انتقل إلى الصفحة الأخيرة',
                'nextPageTooltip': 'انتقل إلى الصفحة التالية',
                'previousPageTooltip': 'انتقل إلى الصفحة السابقة',
                'nextPagerTooltip': 'انتقل إلى عناصر بيجر التالية',
                'previousPagerTooltip': 'للذهاب إلى عناصر بيجر السابقة'
            },
            "dropdowns": {
                "noRecordsTemplate": "لا توجد سجلات"
            },
            "datepicker": {
                "placeholder": "اختر تاريخا",
                "today": "اليوم"
            }
        }
    });
</script>
public IActionResult Index()
{
    var tree = TreeData.GetDefaultData();
    ViewBag.datasource = tree;
    return View();
}

See Also

NOTE

You can refer to our ASP.NET MVC Tree Grid feature tour page for its groundbreaking feature representations. You can also explore our ASP.NET MVC Tree Grid example to knows how to present and manipulate data.