SPF Hotfix for SPCalendarView Bug in Sharepoint 2010
This http://support.microsoft.com/kb/2596998 will fix some bugs in SPCalendarView in Sharepoint 2010 (without doing SPCalendarView.EnableV4Rendering = false that makes it views like Sharepoint 2007).
It will fix some bugs like the contents that doesn’t not show up and the wrong DisplayFormURL value.
Except that coloring content with BackgroundColorClassName still doesn’t work ( it works if SPCalendarView.EnableV4Rendering = false ).
Categories: Bug, Sharepoint
Bug, Sharepoint
I have intalle the hotfix firstly the calandarview it work but after it don’t work
when i use the calView.EnableV4Rendering = false the calandar work properly in wss3.0 interface
Yes it works but looks like WSS3.0/MOSS2007 calendar when SPCalendarView.EnableV4Rendering = false
when i test the calendar in my web part in the site settings webpart component it work properly but in my page she doesn’t work
any idea ?
could you explain more details ? your environment, your source codes …
environment : sharepoint 2010 + Windows 2008 server
My code
//Vars
private const string _ascxPath = @”~/_CONTROLTEMPLATES/Utilities.V3.WebParts/WP-XX-PLA/WP-XX-PLAUserControl.ascx”;
//private const string _ascxPath = @”~/_CONTROLTEMPLATES/Tests_v3.POC_WP_Calendar/WP-CALENDAR/WP-CALENDARUserControl.ascx”;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.Page.ClientScript.RegisterStartupScript(base.GetType(), “CustomCORE.js”, @””, false);
this.EnsureChildControls();
}
protected override void CreateChildControls()
{
Control control = Page.LoadControl(_ascxPath);
Controls.Add(control);
base.CreateChildControls();
try
{
AddCalendar();
}
catch (Exception ex)
{
Controls.Add(new LiteralControl(“Error “));
Controls.Add(new LiteralControl(ex.ToString()));
}
}
///
/// Adds the calendar to web part.
///
private void AddCalendar()
{
var web = SPContext.Current.Web;
//get Data that are gonna be created in the items of the calendar
var results = getDataFromSAPWebService();
//get items
var items = GetCalendarItems(web, results);
var calView = new SPCalendarView();
calView.ViewType = GetCalendarType(Page.Request[“CalendarPeriod”]);
calView.EnableViewState = true;
calView.Width = Unit.Percentage(100);
calView.CssClass = “CnamCalendar”;
//calView.EnableV4Rendering = false;
calView.DataSource = items;
calView.DataBind();
Controls.Add(calView);
}
private DataTable getDataFromSAPWebService()
{
#region Define DataTable to store events
DateTime date_debut;
DateTime date_fin;
DataTable data = new DataTable();
DataColumn id = new DataColumn(“ID”, System.Type.GetType(“System.String”));
id.Unique = true;
data.Columns.Add(“Title”, System.Type.GetType(“System.String”));
//Colonne ID
data.Columns.Add(id);
data.Columns.Add(“EventDate”, System.Type.GetType(“System.String”));
data.Columns.Add(“EndDate”, System.Type.GetType(“System.String”));
data.Columns.Add(“Location”, System.Type.GetType(“System.String”));
data.Columns.Add(“Description”, System.Type.GetType(“System.String”));
data.Columns.Add(“fRecurrence”, System.Type.GetType(“System.Boolean”));
data.Columns.Add(“fAllDayEvent”, System.Type.GetType(“System.Boolean”));
//add ROWS
#warning TODO – Webpart Calendar : Call sap service and fill the dataTable
//titre, ID, date debut, datefin, location, description, recurence de levenement ?, allday
data.Rows.Add(“COURS 1 ECONOMIE”, “2”, DateTime.Parse(“15/05/2012 14:00:00”), DateTime.Parse(“15/05/2012 17:00:00”), “”, “description”, false, false);
}
#endregion
return data;
}
///
/// Gets the collection of calendar items based on site
/// data query results.
///
/// The web that was queried.
/// The results of query.
/// Collection of calendar items accepted by
/// calendar component
private SPCalendarItemCollection GetCalendarItems(SPWeb web, DataTable results)
{
SPCalendarItemCollection items = new SPCalendarItemCollection();
foreach (DataRow row in results.Rows)
{
SPCalendarItem item = new SPCalendarItem();
item.ItemID = row[“ID”] as string;
item.StartDate = DateTime.Parse(row[“EventDate”] as string);
item.EndDate = DateTime.Parse(row[“EndDate”] as string);
item.hasEndDate = true;
item.Title = row[“Title”] as string;
item.Location = row[“Location”] as string;
item.Description = row[“Description”] as string;
item.IsAllDayEvent = (bool)row[“fAllDayEvent”];
item.IsRecurrence = (bool)row[“fRecurrence”];
item.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
//URL when event is clicked
item.DisplayFormUrl = “/”;
//item.BackgroundColorClassName = “test”;
items.Add(item);
}
return items;
}
///
/// Gets the type of the calendar view.
///
/// The type to be checked.
/// Correct view type of calendar.
private static string GetCalendarType(string type)
{
if (type == null)
type = string.Empty;
switch (type.ToLower())
{
case “day”:
return “day”;
case “week”:
return “week”;
default:
return “month”;
}
}
It seems no problem with codes, what’s error actually ?
all links in the calandar not work , so i have insalling the hot fix the same problem that i found
thanks for all.
Is ok for my problem i have a javascript code that bloc my calandar.
this code is windows.load.
if you have an idea for desabled the displayFormURL
like => item.DisplayFormUrl = null.
Just Delete item.DisplayFormURL if you want Not showing it
delete item.DisplayFormURL why?
You want to disable the link didn’t you ?