We are using igLoader to take advantage of the regional support provided by igniteUI. The following is how we instantiate the loader. This appears to work fine.
However, we want the dateTime pattern to be MM/dd/yyyy HH:mm, so we modified the Infragistics.ui.regional-en.js file in the js/modules/i18n/regional folder to indicate these patterns. However, we still get the pattrn M/d/yyyy hh:mm tt when running with the US region.
In this instance, the regional option is begin set to 'en'. Using 'en-US' fails.
How do we change the patterns used for US (or an other region)?
<script type="text/javascript" src="../igniteui/2015.2/js/infragistics.loader.js"></script>
<script> function getLang() { var lang; if (navigator.browserLanguage != undefined) lang = navigator.browserLanguage; else if (navigator.languages != undefined) lang = navigator.languages[0]; else lang = navigator.language; if (lang == "en-US") lang = "en"; return lang; }
$.ig.loader({ scriptPath: "../igniteui/2015.2/js/", cssPath: "../igniteui/2015.2/css/", resources: "igGrid.*,igDialog,igCombo,igHierarchicalGrid.*", regional: getLang() });</script>
Hello hrwebb,
After further investigation it seems that if you set igLoader regional property to "en", the grid loads the default regional settings, without explicitly loading the infragistics.ui.regional-en.js file which you've been modified. If you want the modified regional-en file to be explicitly loaded, you may either pass its relative path to the igLoader resources property, for example:
$.ig.loader({
scriptPath: "http://localhost/ig_ui15.2/js/",
cssPath: "http://localhost/ig_ui15.2/css/",
resources: "igGrid.*, ../js/modules/i18n/regional/infragistics.ui.regional-en.js",
locale: "en",
regional: "en"
});
or set the following before grid initialization:
$.ig.regional.defaults.dateTimePattern= "MM/dd/yyyy HH:mm";
However please note that both approaches work when you set format option to the respective date column. For the current case the format option should be 'dataTime'. If you have any questions, please let me know.
Regards,
Tsanna
Unfortunately, I tried both options and neither one worked.
Fortunately I've found a work-around to accomplish what we need, but I still believe the Infragistics implementation needs adjusting to eliminate the need for users to have to create another regional file or fix existing files to get it to work properly.
Can I help you with anything else?
Another option to fix was to copy the "en" regional file and name it "en-US". This way I can continue to set the regional property to "en-US".
I believe I found the problem.
My region is "en-US". When executing the ig.loader function I have set the regional property to "en-US", but this yields an error that there is no file called infragistics.ui.regional-en-US.js. But there is a file called infragistics.ui.regional-en.js, which is the regional file for "en-US", so I use "en" for the regional property instead.
$.ig.loader({ scriptPath: "../igniteui/2015.2/js/", cssPath: "../igniteui/2015.2/css/", resources: "igGrid.*,igDialog,igCombo,igHierarchicalGrid.*", regional: "en" });
The following code is in the "en" regional file. It checks whether the regional property set when ig.loader was called = "en-US". But as I already said, this fails, so I have to use "en". This version of the file doesn't work for me. But if I change each "en-US" to "en" it works like I need it to. So even if this regional file is used, it would appear that it is never applied and the Infragistics defaults are never changed because the regional property set for the ig.loader can never be "en-US".
(function ($) { $.ig = $.ig || {}; $.ig.regional = $.ig.regional || {}; $.ig.regional['en-US'] = { ... dateTimePattern: 'MM/dd/yyyy', // THIS IS WHERE I ALREADY TRIED CHANGING THE DATETIME FORMAT TO USE ... }; if ($.ig.setRegionalDefault) { $.ig.setRegionalDefault('en-US'); }
I was able to modify the default dateTimePattern format and it works fine. But I really need to be able to use the regional file for "en"in case there are other formats we want to override. Having to do it in code means we'll have to modify all of our html files in the future if we want to change another default pattern rather than change the regional "en"file.
I assume that if it is a region other than "en" we will be able to just modify the respective regional file?
I still think this is a bug to have "en" as the default but not use the "en" regional file to simplify overriding default patterns. It would appear that the regional "en" file isn't necessary and can never be used.