Hi,
I'm trying to show more than one projects on a single GanttChart. I've tried using an xmlProvider an using the structure <Projects><Project><Tasks><Task>, but nothing happens. The xmlProvider throw me an exception "incorrect structure". There's any way to do that?
my code:
My code behind
Any Idea?
Thanks,
I'm trying to show more than one projects on a single GanttChart. I've tried using an xmlProvider an using the structure <Projects><Project><Tasks><Task>, but nothing happens. The xmlProvider throw me an exception "incorrect structure". There's any way to do that?
my code:
<telerik:RadGantt runat="server" ID="GanttChart" CssClass="GanttChart" OnDataBound="GanttChart_DataBound" Skin="Silk" ListWidth="400px" Height="450px" Width="1000px" SelectedView="WeekView" AutoGenerateColumns="false" WorkWeekStart="Monday" WorkWeekEnd="Friday" > <Columns> <telerik:GanttBoundColumn DataField="Title" HeaderText="Attivita" DataType="String" UniqueName="Title" Width="150px" AllowEdit="false"></telerik:GanttBoundColumn> <telerik:GanttBoundColumn DataField="Start" HeaderText="Inizio" DataType="DateTime" UniqueName="Start" DataFormatString="dd/MM/yy" Width="65px" AllowEdit="false" /> <telerik:GanttBoundColumn DataField="End" HeaderText="Fine" DataType="DateTime" UniqueName="End" DataFormatString="dd/MM/yy" Width="65px" AllowEdit="false" /> <telerik:GanttBoundColumn DataField="PercentComplete" HeaderText="Completamento" DataType="Number" UniqueName="PercentComplete" Width="110px" AllowEdit="false" /> </Columns> <YearView UserSelectable="true" /> <DataBindings> <TasksDataBindings IdField="ID" ParentIdField="ParentID" StartField="Start" SummaryField="Summary" EndField="End" TitleField="Title" PercentCompleteField="PercentComplete" OrderIdField="OrderID" /><DependenciesDataBindings TypeField="Type" IdField="ID" PredecessorIdField="PredecessorID" SuccessorIdField="SuccessorID" /> </DataBindings> </telerik:RadGantt>public XElement GetGantTasksByProjectId(int projectId) { using (var db = new HrNoteEntities()) { var tasks = (from t in db.vw_sw_GanttTasks where t.ProjectId == projectId orderby t.ParentId, t.Start select new { ID = t.ID, ParentId = t.ParentId, Start = t.Start, End = t.End, PercentComplete = t.PercentComplete == null ? 0 : t.PercentComplete, Summary = t.Summary == 1 ? true : false, ProjectId = t.ProjectId, Title = t.Title }); XElement tasksList = new XElement("Tasks"); int hasNext = 0; foreach (var item in tasks) { XElement task; if (item.ParentId > 0) hasNext = 0; else hasNext = 1; task = new XElement("Task", new XElement("ID", item.ID), new XElement("ParentID", item.ParentId), new XElement("Start", item.Start.ToString()), new XElement("End", item.End.ToString()), new XElement("Title", item.Title), new XElement("PercentComplete", ((decimal)item.PercentComplete).ToString("G")), new XElement("Summary", item.Summary), new XElement("Expanded", true), new XElement("OrderID", item.ProjectId) ); if (hasNext == 1 && tasksList.HasElements) tasksList.Add(new XElement("NextID", item.ID)); tasksList.Add(task); } return tasksList; } } public XDocument GetGanttByProjectId(int projectId) { XDocument xdoc = new XDocument(); XElement project = new XElement("Project"); xdoc.Declaration = new XDeclaration("1.0", "utf-16", "true"); project.Add(GetGantTasksByProjectId(projectId)); xdoc.Add(project); return xdoc; }// BindingGanttChart.DataSource = model.GetGanttDataSource(selectedProjectId);GanttChart.DataBind();Any Idea?
Thanks,