Is there way to switch between "unit" view and "timeline"?

Is there way to switch between unit view and timeline view on the fly?

I have created timelineview and unitview and and I am downloading data from my server (json) fine and everything works. One of the requirement that I have been told to implement is switching between timeline view and unit view on the fly.

I know we can’t call scheduler.init() multiple times what is other was to re-iniitalize the scheduler to use new view?

i.e. is it possible to switch between timeline view (createTimelineView) and (createUnitsView) when user clicks on a button?

While I am asking questions:

Is there way to lazy load the data i.e. say load the events data only for a current month and when user view changes from one month to next there would be event that causes me to fetch that months data, what kind of event should be looking for that?

Thanks!

-Subodh

You can create both at once ( actually you can create multiple timelines and multiple unit views - there is no limitation on one timeline per scheduler )

Later you can use scheduler.setCurrentView(“timeline”) or scheduler.setCurrentView(“units”) to show the necessary view.

It only works once if I switch from timeline_view to units view I can see the data in unit view.

But if I do gain from unit view to timeline view and then back to unit view, the unit view is empty.
This the code I am using to switch between views.

    $('.dhx_cal_tab[name="unit_tab"]').click( function () {
            console.log("Switching to units view");
            scheduler.setCurrentView( new Date(), "units"); 
            scheduler.parse( eventData, "json");
    });     
    $('.dhx_cal_tab[name="timeline_tab"]').click( function () {
            console.log("Switching to timeline view");
            scheduler.setCurrentView( new Date(), "timeline"); 
            scheduler.parse( eventData, "json");
    });

scheduler.parse( eventData, “json”);
You are using this command each time during view switching, is it has some sense?
Normally data need to be loaded only once, there is no need to reload it during view changing.

If issue still occurs - please provide a demo link or any other kind of sample, where problem can be checked.

I wasn’t sure if I need to do parse the data again after init() actually following code just works fine:

    $('.dhx_cal_tab[name="units_tab"]').click( function () {
            console.log("Switching to units view");
            scheduler.setCurrentView( new Date(), "units"); 
    });     
    $('.dhx_cal_tab[name="timeline_tab"]').click( function () {
            console.log("Switching to timeline view");
            scheduler.setCurrentView( new Date(), "timeline"); 
    });     

Only one question remains: is there way to find out current date that is being viewed?

Right now say someone is looking at calendar for 3 July, 2013 in timeline view, and switches to units view , my code above resets them to current date June 25, 2013.

SO question is there way to find out current date that is being viewed?

Thanks for the help!
-Subodh

scheduler.getState().date

docs.dhtmlx.com/doku.php?id=dhtm … r_getstate

Thank you so much that is cool.

-Subodh