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

RADScheduler as a Webpart

11 Answers 263 Views
Sharepoint Integration
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 18 Aug 2008, 04:53 PM
I'm interested in building a webpart that is essentially the RADScheduler - this will replace the default Sharepoint calendar. I've read several articles on how to create basic webparts with telerik controls, but how would you go about building this webpart as a "fully functional" version of the Scheduler.

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

Sort by
0
Peter
Telerik team
answered on 21 Aug 2008, 12:55 PM
Hi Chad,

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.
0
paddy
Top achievements
Rank 1
answered on 27 Aug 2008, 06:05 AM
hi.........Chad
have you got  solution of RADScheduler as a Webpart?
i am also doing same but i am facing lots of problem .
can you help me out?
or send me some guidelines for d same

Regards
Paddy
0
Chad
Top achievements
Rank 1
answered on 11 Sep 2008, 04:06 PM

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?

0
Dimitar Milushev
Telerik team
answered on 12 Sep 2008, 12:15 PM
Hi Chad,

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.
0
Chad
Top achievements
Rank 1
answered on 12 Sep 2008, 02:49 PM
I got it working by disabling the "EnableViewState" property on the RadScheduler instance.

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?
0
Dimitar Milushev
Telerik team
answered on 12 Sep 2008, 03:53 PM
Hi Chad,

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.
0
Chad
Top achievements
Rank 1
answered on 12 Sep 2008, 04:56 PM
Alright, thanks for your help so far. But I've got another problem... haha.

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:

[ArgumentException: DataKeyField, DataSubjectField, DataStartField and DataEndField are required for databinding]
   Telerik.Web.UI.Scheduling.DataSourceViewSchedulerProvider.EnsureDataFieldsAreSet() +372
   Telerik.Web.UI.Scheduling.DataSourceViewSchedulerProvider.GetAppointments(RadScheduler owner) +82
   Telerik.Web.UI.RadScheduler.PerformSelect() +224
   Telerik.Web.UI.RadScheduler.EnsureDataBound() +94
   Telerik.Web.UI.RadScheduler.CreateChildControls(Boolean bindFromDataSource) +56
   System.Web.UI.Control.EnsureChildControls() +149
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +31
   Telerik.Web.UI.RadScheduler.FindControl(String id, Int32 pathOffset) +23
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +314
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2198


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!!

0
Dimitar Milushev
Telerik team
answered on 15 Sep 2008, 09:19 AM
Hello Chad,

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.
0
Mateusz
Top achievements
Rank 1
answered on 05 Mar 2012, 10:11 AM
Hi Chad,

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
0
Peter
Telerik team
answered on 05 Mar 2012, 05:04 PM
Hello 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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chad
Top achievements
Rank 1
answered on 05 Mar 2012, 05:10 PM
If you're using sharepoint 2010 I did this using a visual web part and it worked out.

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.
Tags
Sharepoint Integration
Asked by
Chad
Top achievements
Rank 1
Answers by
Peter
Telerik team
paddy
Top achievements
Rank 1
Chad
Top achievements
Rank 1
Dimitar Milushev
Telerik team
Mateusz
Top achievements
Rank 1
Share this question
or