Using Calendar as cell editor

Hello,

I am trying to use calendar as a cell editor for a grid, but every time I double click the cell to edit the date the calendar appears and shows january 1970.

I use the example you gave in another post as I didn’t find any docs about this event:

grid.attachEvent("onDhxCalendarCreated",function(calendar){
//calendar - reference to the dhtmlxCalendar object
})

Can I do something so that calendar displays the date in the current cell or if it’s a new entry in the grid then display today’s date?

I have already used the calendar.setSensitive(“2010-01-01”, “2010-12-01”) to disable a date range and calendar.setYearsRange(2010, 2020) , but it still starts from January 1970 and only allows me to select 2010-01-01.

Another problem is if I click on date field and don’t select any date but instead I click somewhere else on the webpage to close the calendar, then it changes the existing cell date to 01/01/1970.

Thank you

Am I doing something wrong here or there is some other issue with the calendar editor?

Thank you

Which value you have in problematic cells? Are they empty or contain some date?

Behavior similar to the above one can be caused by incorrect date format. ( are you using grid.setDateFormat ? ) If calendar can’t parse content of the cell as valid date it fallback to zero date ( which is January 1970 )

Grid is retrieved from server and there 2-3 test records with data. Dates in these rows are like “YYYY-MM-DD” e.g. 2010-01-31, so when I double click on that cell the calendar pops-up but it starts from 1970. Furthermore, if I don’t click on any date and just click somewhere else on the page , the calendar closes but it also modifies the grid cell to 1970-01-01.

Calendar behaves the same way when I insert a new row and grid cell is empty.

I don’t use setDateFormat as according to docs it’s available in the pro version only.

So I suppose I cannot have the calendar working in non-Pro version?

Or I can simply change the date format in DB?

Try to add

grid.setDateFormat("%Y-%m-%d","%Y-%m-%d"); //two parameters!

Normally grid expects to receive data in the default js date format, with above command it must correctly convert dates.

Thanks for the suggestion but Chrome complained with:

Uncaught TypeError: Object #<an Object> has no method 'setDateFormat'

I wouldn’t imagine that JS doesn’t support the The ISO 8601 basic format which is YYYY-MM-DD.

Anyway, I also have to mention that if I don’t use the Calendar editor and just enter any date manually then grid ColValidator properly checks cell contents for a valid date. Any regular YYYY-MM-DD (e.g. 2010-09-01) is correctly validated , if I enter anything like 2010-31-31 grid shows the error.

As for error - setDateFormat exists only in pro version

Default format ( which is expected, when setDateFormat is not used ) is “%d/%m/%Y”