We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Timesheet

Thread ID:

Created:

Updated:

Platform:

Replies:

145769 Jul 5,2019 12:56 PM UTC Jul 9,2019 05:23 PM UTC Angular 1
loading
Tags: ejGantt
Tomasz Tomczykiewicz
Asked On July 5, 2019 12:56 PM UTC

Hi,
Do you have a control that sums hours in columns with tree view? Something like this:https://www.youtube.com/watch?v=9sVa_bkYpy0&feature=youtu.be&hd=1
Best regards,
Tomasz Tomczykiewicz

Pooja Priya Krishna Moorthy [Syncfusion]
Replied On July 9, 2019 05:23 PM UTC

Hi Tomasz, 
 
We can sum all the child values and display in a custom column of parent row by using queryCellInfo event. We can update the custom column values on CRUD operations by using actionComplete event. 
 
Please find the code example below. 
 
[app.component.html] 
<ej-gantt id="GanttControl" [dataSource]="ganttData" (actionComplete)="actionComplete($event)" 
    (queryCellInfo) = "queryCellInfo($event)" > 
      //... 
</ej-gantt> 
[app.component.ts] 
  export class AppComponent { 
    public totalRecords: any = []; 
    constructor() { 
    //... 
    queryCellInfo(args) { 
        if ((args.column.field == "Totalvalue") && args.data.hasChildRecords == true) { 
            var records = this.getChildRecords(args.data, args.model.updatedRecords); 
            var updated_value = ej.sum(records, "Totalvalue"); 
            args.cellValue = updated_value; 
            $(args.cellElement).text(updated_value); 
            this.totalRecords = []; 
        } 
    } 
    actionComplete(args) { 
        if (args.requestType == "recordUpdate") { 
            this.update(args.data.parentItem); 
        } 
        if (args.requestType == "save" && args.addedRecord) { 
            this.update(args.addedRecord.parentItem); 
        } 
        if (args.requestType == "delete") { 
            this.update(args.data.parentItem); 
        } 
    } 
    public getChildRecords(parentRecord, updatedRecords): any { 
        var recordLength = updatedRecords.length, record; 
        for (var length = 0; length < recordLength; length++) { 
            record = updatedRecords[length]; 
            if (parentRecord == record.parentItem) { 
                if (record.hasChildRecords) 
                    this.getChildRecords(record, updatedRecords); 
                else 
                    this.totalRecords.push(record); 
            } 
        } 
        return this.totalRecords; 
    } 
    public update(parentItem) { 
        var totValue = 0; 
        if (parentItem != null) { 
            let childRecords = parentItem.childRecords, 
                len = childRecords.length; 
            for (var i = 0; i < len; i++) { 
                var totalvalue = parentItem.childRecords[i].Totalvalue; 
 
                if (totalvalue) 
                    totValue = totValue + totalvalue; 
                parentItem.Totalvalue = totValue; 
            } 
            let proxy = $('#GanttControl').ejGantt('instance'); 
            let treeGridObj = proxy._$treegridHelper.data("ejTreeGrid"); 
            treeGridObj.refreshRow(treeGridObj.model.updatedRecords.indexOf(parentItem)); 
            return this.update(parentItem.parentItem); 
        } 
    } 
} 
 
 
 
Please find the below sample link. 
 
Regards, 
Pooja Priya K 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon