This is a migrated thread and some comments may be shown as answers.

[Solved] SelectedView

5 Answers 208 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 18 May 2009, 12:25 PM
Hi

Can you tell me what is called when the day week month items at the top are pressed please? as i am trying to do specific things based on what selectedview is currently selected and for some reason when i am setting the selectedview it doesnt seem to change?.

Thanks

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 May 2009, 01:01 PM
Hello Greg,

The NavigationCommand fires when the user clicks on a control that changes the selected day, view, or mode of the scheduler.  

ASPX:
 
<telerik:radscheduler id="RadScheduler1" runat="server" dataendfield="End" datakeyfield="ID" datarecurrencefield="RecurrenceRule" datarecurrenceparentkeyfield="RecurrenceParentID" 
datasourceid="SqlDataSource2" datastartfield="Start" datasubjectfield="Subject" OnNavigationCommand="RadScheduler1_NavigationCommand"
</telerik:radscheduler> 

CS:
 
protected void RadScheduler1_NavigationCommand(object sender, SchedulerNavigationCommandEventArgs e) 
    if (e.Command == SchedulerNavigationCommand.SwitchToDayView) 
    { 
        Response.Write("Switched to Day View"); 
    } 
    else if (e.Command == SchedulerNavigationCommand.SwitchToMonthView) 
    { 
        Response.Write("Switched to Month View"); 
    } 

Thanks,
Shinu.
0
Andrew
Top achievements
Rank 1
answered on 18 May 2009, 01:17 PM
Hi

Thanks thats great, although is it possible for me to change the selected view at that point too? as using the following code It doesnt seem to change? as later on in the page i show data based on this selection.
    protected void RadScheduler1_NavigationCommand(object sender, SchedulerNavigationCommandEventArgs e)  
    {  
        if (e.Command == SchedulerNavigationCommand.SwitchToDayView)  
        {  
            RadScheduler1.SelectedView = SchedulerViewType.DayView;  
        }  
        else if (e.Command == SchedulerNavigationCommand.SwitchToMonthView)  
        {  
            RadScheduler1.SelectedView = SchedulerViewType.MonthView;  
        }    
 
    } 

Thanks
0
T. Tsonev
Telerik team
answered on 18 May 2009, 03:19 PM
Hello Greg,

You can change the view type in this event handler, but you also need to cancel the original event. Otherwise your setting will be ignored.

RadScheduler1.SelectedView = SchedulerViewType.MonthView;
e.Cancel = true;


I hope this helps.

Best wishes,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Andrew
Top achievements
Rank 1
answered on 20 May 2009, 08:49 AM
Hi

I tried adding in the code you sent me, although when clicking day it os still telling me am still in month view and vica versa? Any ideas why its doing that? the only thing i have cnaged is adding in the e.cancel you mentioned?

Thanks
0
Accepted
T. Tsonev
Telerik team
answered on 22 May 2009, 01:20 PM
Hi Greg,

You're right. The current view is still unchanged during the NavigationCommand event. If you want to perform actions after the command has been executed and the view has been changed then you need to handle the NavigationComplete event.

Best wishes,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Scheduler
Asked by
Andrew
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or