<commit_before>---
title: Custom Tasks Fields
page_title: Custom Tasks Fields | RadGantt for ASP.NET AJAX Documentation
description: Custom Tasks Fields
slug: gantt/functionality/custom-tasks-fields
tags: custom,tasks,fields
published: True
position: 5
---

# Custom Tasks Fields


With the 2014 Q2 SP1 version you can now use **Custom Task** objects to populate the **Gantt**,providing you with the ability to add user defined Properties to be shown in the control. In order to use a custom Task class you haveto create a custom Provider, like the one shown in [this help article]({%slug gantt/data-binding/providers/custom-entityframework-provider%}). Sample Code Library can be downloaded from [here](http://www.telerik.com/support/code-library/gantt-custom-columns).

![gantt-custom-tasks-field](images/gantt-custom-tasks-field.png)

## Adding custom fields to Task with custom Entity provider

1.Use previous help article to set up custom Entity Provider

2.Create Custom Task class, inheriting from **Task**.


````C#
public class CustomTask : Task
{
    public CustomTask()
        : base()
    {
    }
}
````
````VB.NET
Public Class CustomTask
    Inherits Task
    Public Sub New()
        MyBase.New()
    End Sub
End Class
````

3.Add custom property


````C#
public class CustomTask : Task
{
    ...
    public string Description
    {
        get { return (string)(ViewState["Description"] ?? ""); }
        set { ViewState["Description"] = value; }
    }
}
````
````VB.NET
Public Class CustomTask
    Inherits Task
    ...
    Public Property Description() As String
        Get
            Return DirectCast(If(ViewState("Description"), ""), String)
        End Get
        Set(value As String)
            ViewState("Description") = value
        End Set
    End Property
End Class
````

4.Override **GetSerializationData** and **LoadFromDictionary** methods


````C#
public class CustomTask : Task
{
    ...
    protected override IDictionary<string, object> GetSerialzationData()
    {
        var dict = base.GetSerialzationData();

        dict["Description"] = Description;

        return dict;
    }

    public override void LoadFromDictionary(System.Collections.IDictionary values)
    {
        base.LoadFromDictionary(values);

        Description = (string)values["Description"];
    }
}
````
````VB.NET
Public Class CustomTask
    Inherits Task
    ...
    Protected Overrides Function GetSerialzationData() As IDictionary(Of String, Object)
        Dim dict = MyBase.GetSerialzationData()

        dict("Description") = Description

        Return dict
    End Function

    Public Overrides Sub LoadFromDictionary(values As System.Collections.IDictionary)
        MyBase.LoadFromDictionary(values)

        Description = DirectCast(values("Description"), String)
    End Sub
End Class
````

5.Create new **TaskFactory**


````C#
public class CustomGanttTaskFactory : ITaskFactory
{
    Task ITaskFactory.CreateTask()<commit_msg>Fix method name typo in article<commit_after>---
title: Custom Tasks Fields
page_title: Custom Tasks Fields | RadGantt for ASP.NET AJAX Documentation
description: Custom Tasks Fields
slug: gantt/functionality/custom-tasks-fields
tags: custom,tasks,fields
published: True
position: 5
---

# Custom Tasks Fields


With the 2014 Q2 SP1 version you can now use **Custom Task** objects to populate the **Gantt**,providing you with the ability to add user defined Properties to be shown in the control. In order to use a custom Task class you haveto create a custom Provider, like the one shown in [this help article]({%slug gantt/data-binding/providers/custom-entityframework-provider%}). Sample Code Library can be downloaded from [here](http://www.telerik.com/support/code-library/gantt-custom-columns).

![gantt-custom-tasks-field](images/gantt-custom-tasks-field.png)

## Adding custom fields to Task with custom Entity provider

1.Use previous help article to set up custom Entity Provider

2.Create Custom Task class, inheriting from **Task**.


````C#
public class CustomTask : Task
{
    public CustomTask()
        : base()
    {
    }
}
````
````VB.NET
Public Class CustomTask
    Inherits Task
    Public Sub New()
        MyBase.New()
    End Sub
End Class
````

3.Add custom property


````C#
public class CustomTask : Task
{
    ...
    public string Description
    {
        get { return (string)(ViewState["Description"] ?? ""); }
        set { ViewState["Description"] = value; }
    }
}
````
````VB.NET
Public Class CustomTask
    Inherits Task
    ...
    Public Property Description() As String
        Get
            Return DirectCast(If(ViewState("Description"), ""), String)
        End Get
        Set(value As String)
            ViewState("Description") = value
        End Set
    End Property
End Class
````

4.Override **GetSerializationData** and **LoadFromDictionary** methods


````C#
public class CustomTask : Task
{
    ...
    protected override IDictionary<string, object> GetSerializationData()
    {
        var dict = base.GetSerializationData();

        dict["Description"] = Description;

        return dict;
    }

    public override void LoadFromDictionary(System.Collections.IDictionary values)
    {
        base.LoadFromDictionary(values);

        Description = (string)values["Description"];
    }
}
````
````VB.NET
Public Class CustomTask
    Inherits Task
    ...
    Protected Overrides Function GetSerializationData() As IDictionary(Of String, Object)
        Dim dict = MyBase.GetSerializationData()

        dict("Description") = Description

        Return dict
    End Function

    Public Overrides Sub LoadFromDictionary(values As System.Collections.IDictionary)
        MyBase.LoadFromDictionary(values)

        Description = DirectCast(values("Description"), String)
    End Sub
End Class
````

5.Create new **TaskFactory**


````C#
public class CustomGanttTaskFactory : ITaskFactory
{
    Task ITaskFactory.CreateTask()
{'fraction_non_alphanumeric': 0.10572390572390572, 'fraction_numerical': 0.00404040404040404, 'mean_word_length': 3.311320754716981, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2007663', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1608, 'n_words': 530}