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

Expected value for Format column in GanttResources?

1 Answer 36 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Diego
Top achievements
Rank 1
Diego asked on 07 Dec 2018, 06:35 PM

Hello,

It says on the documentation that "Another optional column for the Resources Table is Format. This column define the format of the assignment Units and its default value is percentage("p0").".

I have created this column as an nchar(10) (just like the "Color" column) in the GanttResources table and I've tried n0, p0 and c0 as values for my resources but every time the unit displayed is %.

Is there a list of expected values for this column or does it have to be enabled somewhere I'm missing? The documentation about RadGantt doesn't mention this column anywhere else nor do the examples provided use this table in any sort of way.

Thank you for your help!

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 12 Dec 2018, 10:30 AM
Hello Diego,

The format is set to the "Format" property of the resource. Here is how it would look like when the resource format is set: 



In the SQL data table with the resource, the type of the Format column should be nvarchar instead of nchar

Also, if you add the resources programmatically, you can use the following syntax.

// add resources programmatically
 RadGantt1.Resources.Add(new Telerik.Web.UI.Gantt.Resource()
{
    ID = 1,
    Color = Color.Red,
    Text = "Thomas Hardy",
    Format = "n4"
});
RadGantt1.Resources.Add(new Telerik.Web.UI.Gantt.Resource()
{
    ID = 2,
    Color = Color.GreenYellow,
    Text = "Elizabeth Lincoln",
    Format = "p3"
});

Or if you bind the resources from the data source (this example is showing the XML provider scenario): 

<Resources>
  <Resource>
    <ID>1</ID>
    <Text>Thomas Hardy</Text>
    <Color>#f44336</Color>
    <Format>n4</Format>
  </Resource>
  <Resource>
    <ID>2</ID>
    <Text>Elizabeth Lincoln</Text>
    <Color>#880e4f</Color>
    <Format>p3</Format>
  </Resource>
</Resources>

The Resources that the Gantt uses are implementing the IResource and  interfaces: 

namespace Telerik.Web.UI.Gantt
{
    public interface IResourceBase
    {
        object ID { get; set; }
        string Text { get; set; }
        string Format { get; set; }
    }
 
    public interface IResource : IResourceBase, IMarkableStateManager
    {
        Color Color { get; set; }
        IOrderedDictionary GetData();
        void LoadFromDictionary(IDictionary values);
    }
}

For your convenience, I have attached a sample project implementing the suggested approach.

Regards,
Peter Milchev
Progress Telerik
Get quickly and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Gantt
Asked by
Diego
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or