Localization not working for Grid control

Hi, 

I am trying to set custom text for "EmptyRecord" and "ConfirmDelete" in the grid control, but it is not updating. Please see below source code:

I have set following points (highlighted):
  • set Locale="en-GB" in Grid settings
  • Added ej.Grid.Locale["en-GB"] = { ... }; in script.
  • Added reference: <script src="Scripts/ej/i18n/ej.culture.en-GB.min.js"></script>

Can you advise what I am doing incorrect.

Thank you.

-------------------------------------------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Grid.aspx.cs" Inherits="SFGridTest2.Grid" %>
<%@ Register Assembly="Syncfusion.EJ, Version=18.1460.0.42, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Web" TagPrefix="ej" %>
<%@ Register Assembly="Syncfusion.EJ.Web, Version=18.1460.0.42, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Web" TagPrefix="ej" %>
<%@ Register Assembly="Syncfusion.EJ, Version=18.1460.0.42, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Models" TagPrefix="ej" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel='nofollow' href="Scripts/css/flat-azure-2/min/ej.web.all.min.css" rel="stylesheet" />
    <link rel='nofollow' href="Scripts/css/ej.widgets.core.min.css" rel="stylesheet" />
    <script src="Scripts/jquery-3.4.1.min.js"></script>
    <script src="Scripts/jquery.easing1.3.min.js"></script>
    <script src="Scripts/jquery.globalize.min.js"></script>
    <script src="Scripts/jsrender.min.js"></script>
    <script src="Scripts/ej/web/ej.web.all.min.js"></script>
    <script src="Scripts/ej/common/ej.webform.min.js"></script>
    <script src="Scripts/jquery.validate.min.js"></script>
    <script src="Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script src="Scripts/ej/common/ej.unobtrusive.min.js"></script>
    <script src="Scripts/ej/i18n/ej.culture.en-GB.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">

        </asp:ScriptManager>
        <div>
            <h1>Test Grid</h1>
        </div>
        <ej:Grid runat="server" 
            ID="Grid1" 
            AllowSorting="True" 
            AllowGrouping="true" 
            AllowPaging="True"
            AllowSearching="true"
            EnableRowHover="true" 
            OnServerAddRow="Grid1_ServerAddRow" 
            OnServerEditRow="Grid1_ServerEditRow"
            OnServerDeleteRow="Grid1_ServerDeleteRow" 
            ClientIDMode="Static"
            Locale="en-GB" >
            <Columns>
                <ej:Column Field="LocationId" IsPrimaryKey="true" Visible="false"/>
                <ej:Column Field="Hostname" HeaderText="Hostname" TextAlign="Right" EditType="StringEdit">
                    <ValidationRule>
                        <ej:KeyValue Key="required" Value="true" />
                    </ValidationRule>
                </ej:Column>
                <ej:Column Field="LocationVal" HeaderText="Location" EditType="StringEdit">
                </ej:Column>
                <ej:Column Field="NotifGroup" HeaderText="NotifGroup" EditType="StringEdit">
                </ej:Column>
            </Columns>
            <EditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true" AllowEditOnDblClick="true" ShowDeleteConfirmDialog="true" />
            <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel,search" />
        </ej:Grid>
    </form>
</body>
</html>
<script type="text/javascript">
    ej.Grid.Locale["en-GB"] = {
        EmptyRecord: "No Locations have been added.",
        ConfirmDelete: "Are you sure you want to delete this Location?"
    };
</script>


3 Replies

MP Manivannan Padmanaban Syncfusion Team May 5, 2020 11:28 AM UTC

Hi Yazad, 

Greetings from Syncfusion Support. 

The reported issue will occur because the locale labels are defined outside of the form tag. To avoid the issue, we suggest you to define the locale labels within the form tag as like below code example


    <form id="form1" runat="server"> 
        <script type="text/javascript"> 
 
            ej.Grid.Locale["en-GB"] = { 
                EmptyRecord: "No Locations have been added.", 
                ConfirmDelete: "Are you sure you want to delete this Location?" 
            }; 
        </script> 
 
…………………………………. 
 
        <ej:Grid runat="server" 
            ID="Grid1" 
          …………………. 
            Locale="en-GB"> 
            <Columns> 
………………………….. 
            </Columns> 
            ……………….. 
        </ej:Grid> 
    </form> 



Kindly get back to us, if you need further assistance. We will be happy to assist you. 

Regards, 
Manivannan Padmanaban 



YA Yazad May 5, 2020 11:39 AM UTC

Hi Manivannan,

Yes, that was the issue. It is now working after including within form tag.

Thank you for the prompt response.

Regards,
Yazad



MP Manivannan Padmanaban Syncfusion Team May 6, 2020 04:58 AM UTC

Hi Yazad, 

Thanks for the update. 

We are happy to hear that the reported issue has been resolved. 

Kindly get back to us, if you need further assistance. 

Regards, 
Manivannan Padmanaban 


Loader.
Up arrow icon