Basically I want to be able to give users the option via the webpart editor to select a sharepoint list(s) to pull its information from. The list would need to be a calendar list and extra columns would automatically be reflected by the webpart.
For instance, if the calendar list has a "Color" column then that instance of the scheduler would have a Color selection combo box. If the calendar list had a checkbox field called "Active" then that instance of the scheduler would also have a checkbox field called active.
Another option would be to automatically create a list to store the information when the webpart is initialized. This would likely be the default behaviour.
We've tried several webparts to replace the default calendar component in MOSS and nothing comes close to Telerik's Scheduler. The only problem is that it's a control and not a webpart - a "do it yourself" module sounds good, but I'm oblivious to how it would integrate as a webpart with all of the functionality it possesses.
Please let me know if this type of integration is possible without an extremely large amount of coding.
11 Answers, 1 is accepted
Please, find attached a sample webpart with RadScheduler for MOSS. I hope it helps you get started.
We will be glad to assist you further.
Regards,
Peter
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
So I've been slowly chipping away at this webpart, and I've come across some issues. What I have so far is the ability to link the scheduler to a list using a custom toolpart in the "Modify Web Part" properties pane.
The problem is when you change that list, it doesn't automatically update the ListSchedulerProvider after a postback. You actually have to trigger an event in the scheduler to refresh the datasource (ie. click on month view and it'll refresh the datasource based on the new webpart property)
Here is the code that defines the event where the scheduler is bound to its datasource:
protected override void CreateChildControls()
{
this.EnsureUpdatePanelFixups();
UpdatePanel up = new UpdatePanel();
up.ID = "UpdatePanel" + this.UniqueID;
up.ChildrenAsTriggers = true;
up.UpdateMode = UpdatePanelUpdateMode.Always;
theScheduler = new RadScheduler();
theScheduler.Skin = "Office2007";
theScheduler.Width = new Unit(800, UnitType.Pixel);
theScheduler.Height = new Unit(600, UnitType.Pixel);
theScheduler.OverflowBehavior = OverflowBehavior.Expand;
theScheduler.Provider = new ListSchedulerProvider(this.Page.Request.Url.ToString(), _selectedList, _startField, _endField, _titleField);
theScheduler.SelectedView = SchedulerViewType.WeekView;
theScheduler.MonthView.VisibleAppointmentsPerDay = 3;
up.ContentTemplateContainer.Controls.Add(theScheduler);
Controls.Add(up);
}
public override System.Collections.Generic.IEnumerable<Appointment> GetAppointments(RadScheduler owner)
{
List<Appointment> appointmentsList = new List<Appointment>();
Appointment newAppt = new Appointment();
try
{
SPSite oSite = new SPSite(_rootSite);
SPWeb oSites = oSite.OpenWeb();
SPList oList = oSites.Lists[_listName];
foreach (SPListItem listItem in oList.Items)
{
newAppt.Start = DateTime.Parse(listItem.GetFormattedValue(_startField));
newAppt.End = DateTime.Parse(listItem.GetFormattedValue(_endField));
newAppt.ID = Guid.NewGuid();
newAppt.Subject = listItem.GetFormattedValue(_titleField);
newAppt.ToolTip = listItem.GetFormattedValue(_titleField);
newAppt.RecurrenceState = RecurrenceState.NotRecurring;
appointmentsList.Add(newAppt);
}
}
catch(Exception ex)
{
}
return appointmentsList;
}
The reason I wrapped theScheduler in an UpdatePanel is because events were triggering full page postbacks without it... do Scheduler objects have embedded UpdatePanels? If so, why were full page postbacks occuring?
I have a feeling update panels have something to do with the reason its not refreshing, but I can't seem to figure out why. I've tried .Rebind() and I tried forcing the UpdatePanel I added to .Update() but nothing seems to work. Advice?
RadScheduler does not use embedded UpdatePanels and wrapping the Scheduler in an UpdatePanel is a perfectly valid solution.
As for the refresh problem - the Scheduler is probably using the old Provider with the old List. My guess is that by the time your code changes the selected list, the CreateChildControls method has already been executed, creating the ListSchedulerProvider with the old value of _selectedList. You can try recreating the provider and rebinding the Scheduler right after changing the selected list:
// Code that changes the selected list |
theScheduler.Provider = new ListSchedulerProvider(this.Page.Request.Url.ToString(), _selectedList, _startField, _endField, _titleField); |
theScheduler.Rebind(); |
If this does not help, please post the entire code of the WebPart so we have a better overview of what is being executed in what order. If you prefer not to post the code in the public forum, please open a support ticket and attach the code there.
Greetings,
Dimitar Milushev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
theScheduler.EnableViewState = false;
I can't see it resulting in any unwanted behaviour, so I think that solution should work. What side effects would disabling ViewState cause, if any? Perhaps if a list contained a large number of records a viewstate might help to alleviate load times when navigating the different views... is that a correct assumption?
I don't think that there will be a significant performance penalty for disabling the ViewState. SharePoint's caching will probably negate the difference. Also, when navigating between the different views, RadScheduler is rebound and does not load the appointments from the ViewState as it may need to display more appointments than loaded by the previous view.
Sincerely yours,
Dimitar Milushev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Once the webpart properties have been set, specifically the Selected List property, it requires 2 page postbacks to occur before it updates.
I realize that in order to rebind a datasource in a webpart you must override the OnPreRender method, but I can't seem to initialize a ListSchedulerProvider inside that method without receiving this error:
DataKeyField, DataSubjectField, DataStartField and DataEndField are required for databinding
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.ArgumentException: DataKeyField, DataSubjectField, DataStartField and DataEndField are required for databinding
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
|
Here is the relevant code from the webpart, the ListSchedulerProvider is the same as I posted earlier:
private
string _selectedList;
private string _startField;
private string _endField;
private string _titleField;
private string _schedulerTheme = "Default";
RadScheduler theScheduler;
ListSchedulerProvider theProvider;
protected override void OnPreRender(EventArgs e)
{
theProvider =
new ListSchedulerProvider(this.Page.Request.Url.ToString(), _selectedList, _startField, _endField, _titleField);
theScheduler.Provider = theProvider;
theScheduler.Skin = _schedulerTheme;
base.OnPreRender(e);
}
protected override void CreateChildControls()
{
this.EnsureUpdatePanelFixups();
theScheduler = new RadScheduler();
theScheduler.ShowAllDayRow =
true;
theScheduler.TimeZoneOffset =
new TimeSpan(6, 0, 0);
theScheduler.Width =
new Unit(800, UnitType.Pixel);
theScheduler.Height =
new Unit(600, UnitType.Pixel);
theScheduler.OverflowBehavior =
OverflowBehavior.Expand;
//theScheduler.Provider = theProvider;
theScheduler.SelectedView =
SchedulerViewType.WeekView;
theScheduler.MonthView.VisibleAppointmentsPerDay = 3;
theScheduler.EnableViewState =
false;
UpdatePanel up = new UpdatePanel();
up.ID =
"UpdatePanel" + this.UniqueID;
up.ChildrenAsTriggers =
true;
up.UpdateMode =
UpdatePanelUpdateMode.Conditional;
up.ContentTemplateContainer.Controls.Add(theScheduler);
Controls.Add(up);
}
If I initialize the ListSchedulerProvider inside the CreateChildControls method and set theScheduler.Provider there, it works but requires 2 page postbacks before it refreshes the datasource. The interesting thing is that theScheduler.Skin works fine inside the OnPreRender method.
This leads me to believe there is a problem with the way RadScheduler binds to its source that is preventing it from binding in the OnPreRender method.
My question then, where should I:
- Declare the ListSchedulerProvider
- Initialize the ListSchedulerProvider
- Set theScheduler.Provider = ListSchedulerProvider
TIA!!
I would recommend against using the CreateChildControls method. You should override the OnLoad method and move all the code from CreateChildControls there plus the code that initializes your Provider.
Greetings,
Dimitar Milushev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Did you finally managed to integrate this control as webpart?
I'm facing many problems with it and I will be happy if you can give some guidlines for doing it?
Now i'm facing the problem with view's i don't know why when i switch from moth view to week view nothing happens.
Regards
M.Turek
Thank you for your inquiry. Yes, we integrated RadScheduler as a web part in Sharepoint. Here is a help topic for reference - http://www.telerik.com/help/aspnet-ajax/moss-configuring-spradscheduler.html
Regards,
Peter
the Telerik team
The trick is "pre-loading" all necessary javascript either in the masterpage or the visual webpart itself. Otherwise when the page posts back the scripts are not loaded and javascript errors will prevent most things from happening (like switching between views).
I'd check to see if your javascript is getting loaded properly. Depending which browser you're using you can see javascript errors pretty easily.