December 10, 2018, 10:31:26 AM

See more Support incidents in our old archived forum.

Author Topic: [Angular 2] Binding to EndTime by using Effort converter  (Read 750 times)

dniezgoda

  • Customers
  • Newbie
  • *
  • Posts: 18
[Angular 2] Binding to EndTime by using Effort converter
« on: January 02, 2018, 09:44:02 AM »
Hi Support team,

In my angular project, my datasource does not have Effort property, therefore i want to binding to EndDate and using EffortConverter
The problem is i don't know how to call converter logic from .ts file
How to implement the converter logic from .ts file then it can be called directly from .ts
Or call js converter from column template/editor

Thank you in advance!

binding code in my .ts file:
Code: [Select]
mapToGantt(dataSource: any, resources, startTime) {
        // let task = dataSource.sort((a, b) => { return a.SortOrder - b.SortOrder });
        let $granttContainer = $(this.el.nativeElement.querySelector('#gantt_container'));
        let anchorTime = new Date(startTime);
        let $gantt_container = $granttContainer;
        $gantt_container.GanttControl({
            ProjectStartDate: anchorTime,
            DataSource: dataSource,
            IDBinding: new RadiantQ.BindingOptions("ID"),
            CanUserReorderRows: true,
            UseVirtualization: true,
            AutoExpandNodes: false,
            NameBinding: new RadiantQ.BindingOptions("Name"),
            AssignedResourcesBinding: new RadiantQ.BindingOptions("Resources"),
            ResourceItemsSource: resources,
            ResourceIDBinding: new RadiantQ.BindingOptions("ResourceID"),
            ResourceNameBinding: new RadiantQ.BindingOptions("ResourceName"),
            IndentLevelBinding: new RadiantQ.BindingOptions("IndentLevel"),
            StartTimeBinding: new RadiantQ.BindingOptions("StartDate"),
            EndTimeBinding: new RadiantQ.BindingOptions("EndDate"),
            EffortBinding: new RadiantQ.BindingOptions("EndDate", RadiantQ.Gantt.BindingMode.TwoWay, new EffortConverter()),
            SortOrderBinding: new RadiantQ.BindingOptions("SortOrder"),
            PredecessorIndicesBinding: new RadiantQ.BindingOptions("PredecessorIndices"),
            ProgressPercentBinding: new RadiantQ.BindingOptions("ProgressPercent"),
            DescriptionBinding: new RadiantQ.BindingOptions("Description"),
            GanttTableOptions: {
                columns: GanttConfig.GanttColumns
            },

converter in my .js file
Code: [Select]
// EffortConverter Inherits From ValueConverter
        function EffortConverter() {
            RadiantQ.ValueConverter.call(this);
        }
        EffortConverter.prototype = new RadiantQ.ValueConverter();

        // Overriding default Convert and ConvertBack methods
        EffortConverter.prototype.Convert = function (value, parameter) {
            var task = parameter;
            return EffortConverter.GetTaskEffort(task);
        }
        EffortConverter.prototype.ConvertBack = function (value, parameter) {
            // Compute EndTime based on StartTime and Effort.
            var dur = value;
            var task = parameter;
            // Note that "WorkTimeSchedule.Schedule8X5" is the same schdule used by the GanttControl
            // in this app. If you use a different schedule in the GanttControl, use that same schedule here as well:
            return RadiantQ.Gantt.WorkTimeSchedule.Schedule8X5.GetEnd(task.StartTime, dur);
        }
        EffortConverter.GetTaskEffort = function (task) {
            //Note that "WorkTimeSchedule.Schedule8X5" is the same schdule used by the GanttControl
            // in this app. If you use a different schedule in the GanttControl, use that same schedule here as well:
            if (task.StartTime && task.EndTime)
                return RadiantQ.Gantt.WorkTimeSchedule.Schedule8X5.GetEffort(task.StartTime, task.EndTime);

            return RQTimeSpan.Zero;
        }
« Last Edit: January 02, 2018, 09:47:44 AM by dniezgoda »

ForumAdmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 83
Re: [Angular 2] Binding to EndTime by using Effort converter
« Reply #1 on: January 02, 2018, 01:16:39 PM »
Daniel,

Happy New Year!

We are looking into this issue. In the meantime, can you confirm your email by sending a mail to our support mailbox? (support AT radiantq.com)?

Thanks