Home > Bug, Sharepoint > SPF Hotfix for SPCalendarView Bug in Sharepoint 2010

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 Tags: ,
  1. jaafar
    May 28, 2012 at 8:44 am

    I have intalle the hotfix firstly the calandarview it work but after it don’t work

  2. jaafar
    May 28, 2012 at 8:45 am

    when i use the calView.EnableV4Rendering = false the calandar work properly in wss3.0 interface

    • May 28, 2012 at 12:49 pm

      Yes it works but looks like WSS3.0/MOSS2007 calendar when SPCalendarView.EnableV4Rendering = false

  3. jaafar
    May 29, 2012 at 12:52 pm

    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 ?

    • May 29, 2012 at 2:31 pm

      could you explain more details ? your environment, your source codes …

      • jaafar
        May 29, 2012 at 3:11 pm

        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”;
        }
        }

  4. May 30, 2012 at 4:28 am

    It seems no problem with codes, what’s error actually ?

    • jaafar
      May 30, 2012 at 7:59 am

      all links in the calandar not work , so i have insalling the hot fix the same problem that i found

      • jaafar
        May 30, 2012 at 1:36 pm

        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.

  5. May 30, 2012 at 3:53 pm

    Just Delete item.DisplayFormURL if you want Not showing it

  6. jaafar
    May 31, 2012 at 11:06 am

    delete item.DisplayFormURL why?

    • June 1, 2012 at 2:39 am

      You want to disable the link didn’t you ?

  1. No trackbacks yet.

Leave a reply to pak Danan Cancel reply