setCulture causes error when using dateTimePicker | Angular

Hi, I'm trying to get localization to work for ejs grid datetimepickeredit.
I get the error: Cannot convert undefined or null to object node_modules/@syncfusion/ej2-calendars/src/calendar/calendar.js.CalendarBase.getCultureValues

import { setCulture, loadCldr } from '@syncfusion/ej2-base';
loadCldr(
  require('cldr-data/main/en-ZA/numbers.json'),
  require('cldr-data/main/en-ZA/currencies.json'),
  require('cldr-data/supplemental/numberingSystems.json'),
  require('cldr-data/supplemental/currencyData.json'),
);
constructor() {
setCulture('ZA');
}

Please assist

5 Replies

SN Sevvandhi Nagulan Syncfusion Team March 4, 2020 11:56 AM UTC

Hi Ervin, 

Greetings from Syncfusion support. 

We have checked the reported requirement.  The cause of the issue there is no culture file with the mentioned name in the cldr data. To get rid of the reported issue change ZA to en-ZA. Kindly refer the below code, 

constructor() { 
setCulture('en-ZA'); 
} 


If still issue persists, kindly share the whether you are facing the issue while rendering the DatePicker inside the grid or in the individual component? 

Regards, 
Sevvandhi N 



EV Ervin van der Merwe March 4, 2020 01:51 PM UTC

Hi, thanks for the reply. Unfortunately the issue persists with the error: Cannot convert undefined or null to object at Function.keys (<anonymous>) at DatePickerComponent.push../node_modules/@syncfusion/ej2-calendars/src/calendar/calendar.js.CalendarBase.getCultureValues

The control is in the grid as editType='datetimepickeredit'

Any Ideas?
Thanks!


GR Gokul Ramalingam Syncfusion Team March 5, 2020 01:19 PM UTC


Hi Ervin, 

We suspect the problem might be occurring due to the locale property not set properly or the locale files not loaded in the application correctly. We have demonstrated this below where the Grid has Inline edit and DateTimePicker edit for one of the fields and the locale is set as 'en-ZA'. We have also modified the default text for some of them in the L10n.load function to reflect on the Grid. Please refer to the below code snippet and sample link for more information. 

[app.component.ts] 

<ejs-grid [dataSource]="data" 
          #grid id="test" 
          [locale]='en-ZA'        // Apply locale in Grid 
          ………. 
             <e-column field='OrderDate' headerText='Order Date' width='120' editType='datetimepickeredit' textAlign='Right'></e-column> 
            <e-column field='ShipCountry' headerText='Ship Country' width='150' editType='dropdownedit'></e-column> 
        </e-columns> 
</ejs-grid> 


[app.component.ts] 

import { setCulture, loadCldr, L10n } from '@syncfusion/ej2-base'; 

declare let require: any; 
setCulture('en-ZA');           // Set the culture 

L10n.load({ 
  'en-ZA': { 
    'grid': {                  
      "Add": " Add New Record",                // You can change the Locale words here 
      "Edit": "Edit Record", 
      "Cancel": "Cancel Operation", 
      "Update": "Update Record", 
      "Delete": "Remove Record", 
    }, 
    "datetimepicker": { 
      "today": "Todays Date", 
      "placeholder": " Enter a Date" 
    } 
  } 
}); 

constructor() { 
    loadCldr( 
      require('node_modules/cldr-data/main/en-ZA/ca-gregorian.json'),         // Import the required files  
      require('node_modules/cldr-data/main/en-ZA/numbers.json'), 
      require('node_modules/cldr-data/main/en-ZA/timeZoneNames.json'), 
      require('node_modules/cldr-data/supplemental/numberingSystems.json'), 
      require('node_modules/cldr-data/supplemental/currencyData.json'), 
    ); 
  } 




                                      https://ej2.syncfusion.com/angular/documentation/grid/global-local/?no-cache=1 

Please get back to us if you need further assistance. 

Regards, 
Gokul R 



EV Ervin van der Merwe March 11, 2020 06:37 AM UTC

Thanks for the reply.
It is working now


PK Prasanna Kumar Viswanathan Syncfusion Team March 12, 2020 06:53 AM UTC

Hi Ervin, 
 
We are happy to hear that the provided solution has been working fine at your end. 
 
Please get back to us if you need any further assistance. 
 
Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon