Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
200
UltraGanttView Refresh/Reload Data
posted

Hi,

I am using the ultraganttivew control and have the following code:

        private Project _gantProject = null;
        private DataSet _dataSet = new DataSet();
        private DataTable _projectTable = null;
        private DataTable _taskTable = null;

        .............

        private void SetupGant()
        {
            string projectKey = uiJobCode.Text;
            _projectTable = _dataSet.Tables.Add("Projects");
            _projectTable.Columns.Add("ProjectID");
            _projectTable.Columns.Add("ProjectKey");
            _projectTable.Columns.Add("ProjectName");
            _projectTable.Columns.Add("ProjectStartTime", typeof(DateTime));
            // Assign values for each Project member
            _taskTable = _dataSet.Tables.Add("Tasks");
            _taskTable.Columns.Add("TaskID");
            _taskTable.Columns.Add("ProjectKey");
            _taskTable.Columns.Add("TaskName");
            _taskTable.Columns.Add("TaskStartTime", typeof(DateTime));
            _taskTable.Columns.Add("TaskDuration", typeof(TimeSpan));
            _taskTable.Columns.Add("ParentTaskID");
            _taskTable.Columns.Add("Constraint", typeof(object));
            _taskTable.Columns.Add("TaskPercentComplete");
            _taskTable.Columns.Add("CostCode");
            _taskTable.Columns.Add("ResponsiblePerson");
            _taskTable.Columns.Add("Asset");
            _taskTable.Columns.Add("Capitalise", typeof(bool));
            _taskTable.Columns.Add("Enhancement", typeof(bool));
            //The Task properties are all covered by individual members. But we could save space in the database
            //By storing data as binary using AllProperties and not binding the other fields.
            _taskTable.Columns.Add("AllProperties", typeof(Byte[]));
            // Setup Dataset Data for Gant
            LoadGanttData(projectKey);
            _gantProject = this.uiUltraCalendar.Projects.Add("Project Name", DateTime.Today);
            _gantProject.Key = uiJobCode.Text;
            //Add Customer Columns
            //if (!this.uiUltraCalendar.CustomTaskColumns.Exists("CostCode"))
            this.uiUltraCalendar.CustomTaskColumns.Add("CostCode", typeof(String), false, string.Empty);
            this.uiUltraCalendar.CustomTaskColumns.Add("Asset", typeof(String), false, string.Empty);
            this.uiUltraCalendar.CustomTaskColumns.Add("Capitalise", typeof(bool), false, false);
            this.uiUltraCalendar.CustomTaskColumns.Add("Enhancement", typeof(bool), false, false);
            this.uiUltraCalendar.CustomTaskColumns.Add("Id", typeof(Int32), false, 0);
            this.uiUltraCalendar.CustomTaskColumns.Add("ParentId", typeof(Int32), false, 0);
            #region Commented Out
            //  Set the BindingContextControl property to reference this form
            uiUltraCalendar.DataBindingsForTasks.BindingContextControl = this;
            uiUltraCalendar.DataBindingsForProjects.BindingContextControl = this;
            //  Set the DataBinding members for Projects
            uiUltraCalendar.DataBindingsForProjects.SetDataBinding(_dataSet, "Projects");
            uiUltraCalendar.DataBindingsForProjects.IdMember = "ProjectID";
            uiUltraCalendar.DataBindingsForProjects.KeyMember = "ProjectKey";
            uiUltraCalendar.DataBindingsForProjects.NameMember = "ProjectName";
            uiUltraCalendar.DataBindingsForProjects.StartDateMember = "ProjectStartTime";
            //  Set the DataBinding members for Tasks
            uiUltraCalendar.DataBindingsForTasks.SetDataBinding(_dataSet, "Tasks");
            // Basic Task properties
            uiUltraCalendar.DataBindingsForTasks.NameMember = "TaskName";
            uiUltraCalendar.DataBindingsForTasks.DurationMember = "TaskDuration";
            uiUltraCalendar.DataBindingsForTasks.StartDateTimeMember = "TaskStartTime";
            uiUltraCalendar.DataBindingsForTasks.IdMember = "TaskID";
            uiUltraCalendar.DataBindingsForTasks.ProjectKeyMember = "ProjectKey";
            uiUltraCalendar.DataBindingsForTasks.ParentTaskIdMember = "ParentTaskID";
            uiUltraCalendar.DataBindingsForTasks.ConstraintMember = "Constraint";
            uiUltraCalendar.DataBindingsForTasks.PercentCompleteMember = "TaskPercentComplete";
            // All other properties
            uiUltraCalendar.DataBindingsForTasks.AllPropertiesMember = "AllProperties";
            #endregion
            uiGantt.CalendarInfo = this.uiUltraCalendar;
            uiGantt.Project = uiGantt.CalendarInfo.Projects[1];
            uiGantt.GridSettings.ColumnSettings["Capitalise"].Visible = Infragistics.Win.DefaultableBoolean.False;
            uiGantt.GridSettings.ColumnSettings["Enhancement"].Visible = Infragistics.Win.DefaultableBoolean.False;
            uiGantt.GridSettings.ColumnSettings["Id"].Visible = Infragistics.Win.DefaultableBoolean.False;
            uiGantt.GridSettings.ColumnSettings["ParentId"].Visible = Infragistics.Win.DefaultableBoolean.False;
            uiGantt.GridSettings.ColumnSettings[TaskField.Dependencies].Visible = Infragistics.Win.DefaultableBoolean.False;
        }
        private void LoadGanttData(string projectKey)
        {
            _dataSet.Clear();
            _projectTable.Rows.Add(new Object[] { Guid.NewGuid(), projectKey, "JobProjects", DateTime.Today });
            _jobTasks = _jobTasksAdapter.GetDataByJob(projectKey);
            Dictionary<int, string> parentChildDict = new Dictionary<int, string>();
            int count = 0;
            Guid parentGuid = Guid.NewGuid();
            foreach (QIT_Backoffice.Data.DB.Jobs.JobTasksRow row in _jobTasks.Rows)
            {
                if (count == 0)
                {
                    _taskTable.Rows.Add(new Object[] { parentGuid, projectKey, row.Description, row.StartDate, TimeSpan.FromDays(2), null, TaskConstraint.StartNoEarlierThan, row.PercentageCompleted, row.CostCode, row.ResponsiblePerson, row.Asset, row.Capitalise, row.Enhancement });
                }
                else
                {
                    _taskTable.Rows.Add(new Object[] { Guid.NewGuid(), projectKey, row.Description, row.StartDate, TimeSpan.FromDays(2), parentGuid, TaskConstraint.StartNoEarlierThan, row.PercentageCompleted, row.CostCode, row.ResponsiblePerson, row.Asset, row.Capitalise, row.Enhancement });
                }
                count++;
            }
            DataRow taskRow = null;
            foreach (Task tsk in this.uiUltraCalendar.Tasks)
            {
                taskRow = _taskTable.Select(string.Format("TaskID = '{0}'", tsk.Id)).FirstOrDefault();
                tsk.SetCustomProperty("CostCode", taskRow["CostCode"].ToString());
                tsk.SetCustomProperty("Asset", taskRow["Asset"].ToString());
                tsk.SetCustomProperty("Capitalise", (bool)taskRow["Capitalise"]);
                tsk.SetCustomProperty("Enhancement", (bool)taskRow["Enhancement"]);
            }
        }
I have an event which gets fired when you update text on a text field and calls the following code:
            LoadGanttData(uiJobCode.Text);
            uiGantt.CalendarInfo = this.uiUltraCalendar;
            uiGantt.Project = uiGantt.CalendarInfo.Projects[1];
This code re-loads the data, but it does keep the parent/child link? That is removed? After calling the three lines of code just above, it seems that all the Tasks are now parent tasks as the Parent field of the Tasks is somehow set to null? But when I call the code for the first time it works fine? What is the best way to reload the DataSet which is binded to the ultraganttivew control?
Parents Reply Children
No Data