Print Page | Close Window

How To switch back in day mode?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=10157
Printed Date: 19 May 2024 at 1:47pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How To switch back in day mode?
Posted By: prashant
Subject: How To switch back in day mode?
Date Posted: 09 April 2008 at 9:32am
As per shown in the example I added multiple schedules. Now I want to switch back in Day mode/View. How to achieve this?



Replies:
Posted By: prashant
Date Posted: 10 April 2008 at 1:37am
Hi Oleg,

We have Day, 2 Days, Week, 2 Weeks, Month and Multi Schedule Views for Calendar.

Issue:
When we want to go back to "Day" View from "MultiShedule" View, View is not getting changed to DAY View and not getting displayed.

Thanks in advance.


Posted By: Algae
Date Posted: 01 May 2008 at 4:48pm

As you probably discovered there's no method illustrated in the samples to revert to the original "day view" mode after using a multiple configuration. However, it is possible.

What you need to do is recreate the original calendar resource. When you debug you can see that there is indeed a calendar resource created when you start in day view mode.  It has a blank string for name so it doesn't display anything at the top of the calendar.

Here is an example of using a new resource when switching to restore day view mode:

void CCalendarDoc::OnScheduleSelect()
{
    CSchedDlg dlg;
    int nDlgRes = (int)dlg.DoModal();
    if (nDlgRes == IDOK)
    {
        CXTPCalendarControl* pCalendar = GetCalendarCtrl();

        if ( dlg.m_pResources->GetCount() )
        {
            pCalendar->SetResources(dlg.m_pResources);
            pCalendar->Populate();
            pCalendar->RedrawControl();
        }
        else
        {
            CXTPCalendarResource *pResource = new CXTPCalendarResource(pCalendar);
            if (!pResource)
                ASSERT(FALSE);

            pResource->SetDataProvider(pCalendar->GetDataProvider());
            pResource->SetName(_T(""));
            pCalendar->GetResources()->Add(pResource);

            for (int i = 0; i < pCalendar->GetResources()->GetCount(); i++ )
            {
                if (pResource->GetName() != _T("") )
                    pCalendar->GetResources()->RemoveAt(i);
            }
        }
    }

There are probably other, better ways of doing this but this works. I tried a couple other approaches which failed and I'm not 100% sure why, but I believe it's due to the way smart pointers are used.

A couple of things to avoid:

1. GetResources->RemoveAll() will fail. 
2. Maintaining a copy of the original resource and trying to reuse it will fail and it's scarcely worth the effort.

Hope this helps you out. It takes some digging to see exactly what the system expects. Maybe CJ can include the methodology in their sample so others aren't stuck on this.






Posted By: KumarCJ
Date Posted: 23 July 2008 at 2:18am
Hi,
 
I have one doubt, I implemented two modes 1) Multischedule and 2) Day
 
In multischedule mode I can see newly added scedules (Columns) but when I try to switch back to Day mode Columns remains as it is.
 
My question is
 
How to remove schedules while switching back to Day mode?
 
I tried following code but CAlendar cntrol is turning whole RED
 
Code:-
 
CXTPCalendarControl* pCalendarCtrl = &this->GetCalendarCtrl();
CXTPCalendarData * pData = pCalendarCtrl->GetDataProvider();
if (!pData)
    return;
  
pSchedules = pData->GetSchedules();
  
  
if (!pSchedules)
     return;  
            

int iCnt = pCalendarCtrl->GetResources()->GetCount();  
// Here I am getting proper column/schedule count (2)
for (int i = 0; i < iCnt; i++ )
{
     pCalendarCtrl->GetResources()->RemoveAt(0);
}
 
Thanks in advance.


Posted By: Algae
Date Posted: 25 July 2008 at 3:16am
Not 100% sure of what's going on based on your code, but I did not see in your code where you set the original provider again.

Set new (same as original) provider:

pCalendar->SetDataProvider(GetDataProvider(), FALSE);

where GetDataProvider() returns your original provider such as SQLDataProvider etc.

You have to set the new (old!) provider in order to repopulate.




Posted By: AndreiM
Date Posted: 06 August 2008 at 2:42pm
Hello,
You are right.
CXTPCalendarControl::SetDataProvider is used to easy set a single resource.
CXTPCalendarControl::SetResources is used to set one or few resources.
 
Calendar is multi-scheduled in the kernel. There is no special single resource mode. 
If you set only one resource - it just does not show resource header (name) by default .
 
KumarCJ in his code remove all resources and does not add one.
 
GetDataProvider() simply return first resource data provider.
 
FYI. Each resource may have own separate data provider as far as one data provider may be used for many resources.
 


-------------
Regards,
Andrei Melnik



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net