This is a migrated thread and some comments may be shown as answers.

Custom Task Field is Not Showing up in the TreeView

2 Answers 126 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Binal
Top achievements
Rank 1
Binal asked on 21 Aug 2015, 07:21 AM

Hello,

 I have added One Custom Task Field 'SrNo' as object datatype with respect to demo project given here. I have not used EntityFramework. I am Binding RadGantt's Datasource and DependenciesDataSource simply on Page_Load Event.

To add new Task Field below is the code I have written

public class CustomGanttTaskFactory : ITaskFactory
  {
      Task ITaskFactory.CreateTask()
      {
          return new CustomTask();
      }
  }
 
  public class CustomTask : Task
  {
      public CustomTask()
          : base()
      {
      }
 
      public object SrNo
      {
          get { return (object)(ViewState["SrNo"] ?? ""); }
          set { ViewState["SrNo"] = value; }
      }
 
      protected override IDictionary<string, object> GetSerializationData()
      {
          var dict = base.GetSerializationData();
          dict["SrNo"] = SrNo;
          return dict;
      }
 
      public override void LoadFromDictionary(System.Collections.IDictionary values)
      {
          base.LoadFromDictionary(values);
 
          SrNo = values["SrNo"];
      }
  }

Page_Load Event:

protected void Page_Load(object sender, EventArgs e)
   {
       List<ITask> newFinalTask = new List<ITask>();
       List<IDependency> FinalDependency = new List<IDependency>();
       newFinalTask.Add(new CustomTask { ID = 1, SrNo = "1", OrderID = 1, ParentID = null, Title = "A", Start = new DateTime(2015, 01, 10, 0, 0, 0), End = new DateTime(2015, 01, 19, 23, 59, 59), PercentComplete = 0.60M, Expanded = false, Summary = true });
       newFinalTask.Add(new CustomTask { ID = 2, SrNo = "", OrderID = 2, ParentID = 1, Title = "A1", Start = new DateTime(2015, 01, 10, 0, 0, 0), End = new DateTime(2015, 01, 15, 23, 59, 59), PercentComplete = 0.60M, Expanded = false });
       newFinalTask.Add(new CustomTask { ID = 3, SrNo = "", OrderID = 3, ParentID = 1, Title = "A2", Start = new DateTime(2015, 01, 16, 0, 0, 0), End = new DateTime(2015, 01, 19, 23, 59, 59), PercentComplete = 0.60M, Expanded = false });
       newFinalTask.Add(new CustomTask { ID = 4, SrNo = "2", OrderID = 4, ParentID = null, Title = "B", Start = new DateTime(2015, 01, 20, 0, 0, 0), End = new DateTime(2015, 01, 31, 23, 59, 59), PercentComplete = 0.60M, Expanded = false, Summary = true });
       newFinalTask.Add(new CustomTask { ID = 5, SrNo = "", OrderID = 5, ParentID = 4, Title = "B1", Start = new DateTime(2015, 01, 20, 0, 0, 0), End = new DateTime(2015, 01, 31, 23, 59, 59), PercentComplete = 0.60M, Expanded = false });
 
       FinalDependency.Add(new Dependency { ID = 1, PredecessorID = 1 ,SuccessorID = 4, Type = DependencyType.FinishStart });
 
       RadGantt1.DataSource = newFinalTask;
       RadGantt1.DependenciesDataSource = FinalDependency;
   }

 

Design Page:

<telerik:RadGantt runat="server" ID="RadGantt1"
    Enabled="true"
    ReadOnly="True"
    AllowSorting="False">
 
    <DataBindings>
        <TasksDataBindings IdField="ID" TitleField="Title" StartField="Start" EndField="End"
            PercentCompleteField="PercentComplete" OrderIdField="OrderID" SummaryField="Summary" ParentIdField="ParentID"  />
        <DependenciesDataBindings IdField="ID" PredecessorIdField="PredecessorID"
            SuccessorIdField="SuccessorID" TypeField="Type" />
    </DataBindings>
 
    <CustomTaskFields>
        <telerik:GanttCustomField PropertyName="SrNo" ClientPropertyName="SrNo"/>
    </CustomTaskFields>
 
    <Columns>
        <telerik:GanttBoundColumn DataField="ID" HeaderText="ID" AllowEdit="false" AllowSorting="false" Width="50px"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumn DataField="SrNo" HeaderText="Sr.No." AllowEdit="false" AllowSorting="false" Width="50px" UniqueName="SrNo"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumn DataField="Title" HeaderText="ACTIVITY" AllowEdit="false" AllowSorting="false"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumn DataField="Start" HeaderText="START" DataFormatString="dd/MM/yyyy" AllowEdit="false" AllowSorting="false" Width="80px"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumn DataField="End" HeaderText="END" DataFormatString="dd/MM/yyyy" AllowEdit="false" AllowSorting="false" Width="80px"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumn DataField="PercentComplete" HeaderText="% COMPLETED" AllowEdit="false" AllowSorting="false"></telerik:GanttBoundColumn>
    </Columns>
 
</telerik:RadGantt>

But it is not Displaying Data in Sr.No. Field. Below Attached is the output Image.

Please help me with what is wrong with my code.

 

 

2 Answers, 1 is accepted

Sort by
0
Binal
Top achievements
Rank 1
answered on 24 Aug 2015, 08:44 AM
Sorry, here is the change of ClientPropertyName property of CustomTaskFields.
<CustomTaskFields>
        <telerik:GanttCustomField PropertyName="SrNo" ClientPropertyName="srNo"/>
</CustomTaskFields>​
0
Sebastian
Top achievements
Rank 1
answered on 13 Jul 2017, 04:01 PM
This is something late, I try to make the same, but I can not. My custom task column is shown with the value "undefined".

Any idea?

Thanks
Tags
Gantt
Asked by
Binal
Top achievements
Rank 1
Answers by
Binal
Top achievements
Rank 1
Sebastian
Top achievements
Rank 1
Share this question
or