Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Custom Task Field is Not Showing up in the TreeView

$
0
0

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

publicclassCustomGanttTaskFactory : ITaskFactory
  {
      Task ITaskFactory.CreateTask()
      {
          returnnewCustomTask();
      }
  }
 
  publicclassCustomTask : Task
  {
      publicCustomTask()
          : base()
      {
      }
 
      publicobjectSrNo
      {
          get{ return(object)(ViewState["SrNo"] ?? ""); }
          set{ ViewState["SrNo"] = value; }
      }
 
      protectedoverrideIDictionary<string, object> GetSerializationData()
      {
          var dict = base.GetSerializationData();
          dict["SrNo"] = SrNo;
          returndict;
      }
 
      publicoverridevoidLoadFromDictionary(System.Collections.IDictionary values)
      {
          base.LoadFromDictionary(values);
 
          SrNo = values["SrNo"];
      }
  }

Page_Load Event:

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

 

Design Page:

<telerik:RadGanttrunat="server"ID="RadGantt1"
    Enabled="true"
    ReadOnly="True"
    AllowSorting="False">
 
    <DataBindings>
        <TasksDataBindingsIdField="ID"TitleField="Title"StartField="Start"EndField="End"
            PercentCompleteField="PercentComplete"OrderIdField="OrderID"SummaryField="Summary"ParentIdField="ParentID"  />
        <DependenciesDataBindingsIdField="ID"PredecessorIdField="PredecessorID"
            SuccessorIdField="SuccessorID"TypeField="Type"/>
    </DataBindings>
 
    <CustomTaskFields>
        <telerik:GanttCustomFieldPropertyName="SrNo"ClientPropertyName="SrNo"/>
    </CustomTaskFields>
 
    <Columns>
        <telerik:GanttBoundColumnDataField="ID"HeaderText="ID"AllowEdit="false"AllowSorting="false"Width="50px"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumnDataField="SrNo"HeaderText="Sr.No."AllowEdit="false"AllowSorting="false"Width="50px"UniqueName="SrNo"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumnDataField="Title"HeaderText="ACTIVITY"AllowEdit="false"AllowSorting="false"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumnDataField="Start"HeaderText="START"DataFormatString="dd/MM/yyyy"AllowEdit="false"AllowSorting="false"Width="80px"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumnDataField="End"HeaderText="END"DataFormatString="dd/MM/yyyy"AllowEdit="false"AllowSorting="false"Width="80px"></telerik:GanttBoundColumn>
        <telerik:GanttBoundColumnDataField="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.

 

 


Viewing all articles
Browse latest Browse all 94857

Latest Images

Trending Articles



Latest Images