Project task list of SharePoint 2010 display in Gantt view by using Web part

Dotaz Project task list of SharePoint 2010 display in Gantt view by using Web part

  • 20 เมษายน 2555 5:47
     
     

    How do I ensure that the Project task list of SharePoint 2010 displays in Gantt view when used in a web part?

    I have a site with a Project Task List, which has a custom Gantt view as the default view. The home page of the site, which is not a wiki page, has a List View Web Part for the Task List where the Gantt view is selected but the the list is not showing in Gantt view and instead showing an standard view which is not required.

    When you drop the Project task list on the page as a web part, it should be showing the gantt view since it is the default view but it is still showing as the standard view.We have also verified it from the code by getting the ViewGuid of the currently selected view to ensure that the correct view is being selected and the view selected is the correct one but not showing the Gantt chart.

    The only way it shows the Gantt view is when you edit the web part of the Project task list and without editing anything, just click the OK button and again refresh the page.Now, it will display the gantt view properly.I have compared the html source of both the pages i-e With Gantt view shown and without the Gantt view, it was found that a javascript snippet was inserted into the page that was showing the correct Gantt view and that javascript code shown below was causing the gantt view to be displayed.

          var WebPartWPQ2_JSGridController;

                        (function(){

                           function TryCreateGrid()

                           {

                               if (WebPartWPQ2_JSGridController == null)

                               {

                                   WebPartWPQ2_JSGridController = new SP.GanttControl();

                               }

                           }

                           function InitGrid()

                           {

                              SP.UI.Workspace.remove_resized(InitGrid);

                              TryCreateGrid();

                              WebPartWPQ2_JSGridController.Init(new SP.JsGrid.JsGridControl($get('ListViewWebPartJSGrid'), true),

                           Sys.Application.add_init(TryCreateGrid);

                           SP.UI.Workspace.add_resized(InitGrid);

                        })();

     

      The above code is creating a JSGrid control which is showing the gantt view but why is it not showing the gantt view without editing the webpart.

      Kindly let me know if any one has some idea regarding this issue.