Setting locale to calendar of form\grid

Hello :slight_smile:
I came to need of setting this “special” lang in form\grid calendar.
And that’s what I came up with in the end.

That goes into

			function prepareCalendar(cal,loc)
			{
				if (loc == "fi")
				{
					dhtmlXCalendarObject.prototype.langData["fi"] = 
					{
						dateformat: "%d.%m.%Y",
						monthesFNames: ["Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu"],
						monthesSNames: ["Tam", "Hel", "Maa", "Huh", "Tou", "Kes", "Hei", "Elo", "Syy", "Lok", "Mar", "Jou"],
						daysFNames: ["Sunnuntai", "Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai"],
						daysSNames: ["Su", "Ma", "Ti", "Ke", "To", "Pe", "La"],
						weekstart: 1
					}
				}
				cal.loadUserLanguage(loc);
			}

And now, in form init (after my_form object is created and filled) we add

		my_form.attachEvent("onXLE", function (){
    		//any custom logic here
			var c = projectform_form.getCalendar("MY_CALENDAR_ITEM");
			prepareCalendar(c,p_language_id);
		});

.
For grids it is a bit dirtier…
Grid does not have this calendar object in easy access, like form, so we adress it like this

		mys_grid.attachEvent("onRowDblClicked", function(rId,cInd){
				prepareCalendar(my_grid._grid_calendarA,"p_language_id");
				return true;
			});  

In other words - each time someone is trying to access special editors(doubleclick cell) - we try to set locales.

Imho that is verry dirty way, but it works…

So, in the end all you have to do - edit this header part

Hope I’ve saved someone a few hours )
Sincerelly.

Note please that for FORM - you have to repeat these 2 lines

         var c = projectform_form.getCalendar("MY_CALENDAR_ITEM");
         prepareCalendar(c,p_language_id);

for each calendar item that you have on it…

In case of calendar in grid you may use onCalendarShow event:

mygrid.attachEvent("onCalendarShow", function(myCal,rId,colInd){ myCal.loadUserLanguage(loc); })