How to: mantain selection of row when I drag and drop tasks programmatically + How to: cut and paste records in Gantt control

Hi,

I was wondering if there's a way to:

1. Mantain selection when reordering tasks in tree grid by mean of a custom toolbar button (Move Up, Move Down). Also, what is the best way to validate the dropped row (eg. the level should remain the same)?

2. Is there a way to tweak the copy and paste function in the Gantt control to have a cut and paste function?

Thank you so much for your time.

Marco

22 Replies 1 reply marked as answer

MS Monisha Sivanthilingam Syncfusion Team March 12, 2021 03:48 AM UTC

Hi Marco,  
 
Currently we are validating this. We will update you further details in one business day(March 12, 2021).  
Until then we appreciate your patience.  
 
Regards,  
Monisha 



MS Monisha Sivanthilingam Syncfusion Team March 12, 2021 11:40 AM UTC

Hi Marco, 
 
Thank you for contacting Syncfusion support. 
 
Please find the response for your queries below. 
 
Sl.No. 
Query 
Syncfusion Comments 
 
1 
Mantain selection when reordering tasks in tree grid by mean of a custom toolbar button (Move Up, Move Down). 
We have made use of the reorderRows method to achieve your requirement. We have made use of the reorderRows method to move the record above or below through a toolbar click and we have made use of the selectRow method in the actionComplete event to maintain selection. The following code snippets demonstrate the solution. 
 
App.component.ts 
public toolbarClick(args: any): void { 
    if (args.item.text === "Move Up") { 
      let selectedrowindex: number = this.ganttObj.selectionModule.getSelectedRowIndexes(); 
      this.selectedRecord = this.ganttObj.selectionModule.getSelectedRecords(); 
      this.movingto = selectedrowindex[0] - 1; 
      this.ganttObj.reorderRows(selectedrowindex, this.movingto, "above"); 
    } 
    if (args.item.text === "Move Down") { 
      debugger; 
      let selectedrowindex: number = this.ganttObj.selectionModule.getSelectedRowIndexes(); 
      this.selectedRecord = this.ganttObj.selectionModule.getSelectedRecords(); 
      this.movingto = selectedrowindex[0] + 1; 
      this.ganttObj.reorderRows(selectedrowindex, this.movingto, "below"); 
    } 
  } 
public actionComplete(args: any) { 
    if (args.requestType == "refresh") { 
      for (var i = 0; i < this.ganttObj.currentViewData.length; i++) { 
        if ( 
          this.ganttObj.currentViewData[i].TaskID == 
          this.selectedRecord[0].TaskID 
        ) { 
          this.ganttObj.selectionModule.selectRow(i); 
        } 
      } 
    } 
  } 
 
 
We have prepared a sample for your reference. 
 
2 
Is there a way to tweak the copy and paste function in the Gantt control to have a cut and paste function? 
We have made use of the reorderRows to achieve your requirement. We have moved the records to the selected position. The following code snippets demonstrate the solution. 
 
App.component.ts 
public contextMenuClick(args: ContextMenuClickEventArgs) { 
    debugger; 
    if (args.item.id === "cut") { 
      this.copiedRecord = args.rowData; 
    } 
    if (args.item.id === "paste") { 
      this.ganttObj.reorderRows( 
        this.copiedRecord.taskData.TaskID, 
        args.rowData.TaskID, 
        "below" 
      ); 
      this.copiedRecord = undefined; 
    } 
  } 
  public contextMenuOpen(args: ContextMenuOpenEventArgs) { 
    if (args.type !== "Header") { 
      if (this.copiedRecord) { 
        args.hideItems.push("Cut"); 
      } else { 
        args.hideItems.push("Paste"); 
      } 
    } 
  } 
 
We have prepared a sample for your reference. 
 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 



MA Marco March 12, 2021 04:54 PM UTC

Hi Monisha,

thank you so much for your reply and the code snippet you provided. I'll test it and let you know if I have any trouble :).

I have another question for you. I know there is the possibility to define segments (split tasks) on child tasks; Is there something we can do to apply the same logic to the parent element? 


Thank you so much,
Marco




MA Marco March 12, 2021 07:01 PM UTC

Hi,

I just discorvered that the reorderRows method doesn't update the index of the row. Is it the correct behaviour? For instance, when i cut a record and than paste it once I re-copy it i see that it has the old index, and thus the cut and paste operation doesn't work as expected. Moreover, I see that you used the TaskID field in the reorderRows method in the sample you provided for my second question. Should be the index, right?


Marco 


MS Monisha Sivanthilingam Syncfusion Team March 15, 2021 12:59 PM UTC

Hi Marco, 
 
We are currently validating your query. We will provide you with a solution within one business day(16-03-2021). 
 
We appreciate your patience until then. 
 
Regards, 
Monisha. 



MA Marco March 18, 2021 06:07 PM UTC

Any update on this?

Thanks,
Marco


MS Monisha Sivanthilingam Syncfusion Team March 19, 2021 08:33 AM UTC

Hi Marco, 
 
You are welcome. 
 
Please find the response for your queries below. 
 
Sl.No. 
Query 
Syncfusion Comments 
 
1 
I know there is the possibility to define segments (split tasks) on child tasks; Is there something we can do to apply the same logic to the parent element? 
We cannot define segments for parent tasks. As parent tasks render based on their child tasks, it is not possible to define segments for parents. 
2 
I just discorvered that the reorderRows method doesn't update the index of the row. Is it the correct behaviour? 
We have maintained the index of the records after row drag and drop actions are performed in the server side using the rowDrop event. Please refer to the following Online Documentation for more information. 
 
 
Meanwhile, we will consider this as a feature request. We have logged a feature report for this. You can track its status from the below feedback link. 
 
 
However, as we have already lined up some major features, we could not implement this support immediately. We will implement this and include it in any of our upcoming releases. Please cast your vote on this feature based on the customer demand we will prioritize the features in our upcoming road map. 
 
 
We have also prepared a sample for your reference. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 



MA Marco April 13, 2021 12:06 PM UTC

Hi Monisha,

I got some troubles with drag and drop when changing the Gantt viewType in "Resource view". Any idea why this happens?

Marco


MS Monisha Sivanthilingam Syncfusion Team April 14, 2021 09:05 AM UTC

Hi Marco, 
 
We were able to replicate the issue you reported and have considered it as a bug from our side. We have logged a bug report for it. You can track its status from the below feedback link. 
 
 
The fix will be provided in the patch release scheduled on April 28, 2021. 
 
We appreciate your patience until then. 
 
Regards, 
Monisha. 



MS Monisha Sivanthilingam Syncfusion Team April 28, 2021 12:38 PM UTC

Hi Marco, 
 
Thank you for your patience. 
 
The issue reported in feedback 24280 has been fixed in version v19.1.58. Please find the release notes from the below link. 
 
 
We have also prepared a sample demonstrating the fix. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 


Marked as answer

MA Marco April 29, 2021 06:44 PM UTC

Hi Monisha,

thank you for the update. 
I see the row drag and drop works now, but in my project it works only when allowEditing is set to true, otherwise it gives an error on the property dialogEditValidationFlag of the EditModule, as shown in the image below:



Moreover, I have the requirement of reordering the rows (dragging, moving up or down and copy and paste them) also inside the same resource. I saw in the source code that there are some  (either for the drag operation or for the moveRow with the reorderRows method) which prevent the movement of a record inside the same resource.

What I'm trying to achieve here is, when I move a row, I want to update some data which are bound to the Gantt component. 

Any workaround? Any help would be very appreciated.

Thank you,
Marco





MS Monisha Sivanthilingam Syncfusion Team April 30, 2021 12:46 PM UTC

Hi Marco, 
 
You are welcome. 
 
We would like to inform you that it is mandatory to set allowEditing to true when performing row drag and drop actions in Resource View as we make use of a few methods from editModule during row drag and drop. Hence, it is mandatory to set allowEditing as true when performing row drag and drop actions. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 



MA Marco April 30, 2021 01:16 PM UTC

Hi Monisha,

thank for the clarification. The previous question has another section relative to the requirement of dragging inside the same resource. Please check my previous post for details.

Marco


MS Monisha Sivanthilingam Syncfusion Team May 3, 2021 09:51 AM UTC

Hi Marco, 
 
You are welcome. 
 
We would like to inform that it is not possible to drag and drop within the same resource. The records are arranged inside each resource according to their TaskID values. Hence. It is not possible to drag and drop records within the same resource. However, you cand drag and drop records over multiple resources. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 



MA Marco May 3, 2021 10:11 AM UTC

Hi Monisha,

I see in Project View it is possible. The main goal for us is to provide the functionality of rearranging rows inside the gantt and update some data, such as a priority field which we bound to the data source.
 At the same time, we want to mantain the Resource View which outlines, when in collapsed state, the "holes" btw tasks (cfr split task on parent item). Any suggestion? Thank you so much for your time.

Marco


MS Monisha Sivanthilingam Syncfusion Team May 4, 2021 09:52 AM UTC

Hi Marco, 
  
We can make use of the reorderRows method to move rows in the Gantt Chart programmatically. However, we cannot use this method to move rows within the same resource. We can only move rows among multiple resource. We would like to inform you that all changes made in the project view are maintained in the resource view. To learn more about reorderRows method in Gantt Chart, please refer our Online Documentation. 
  
We hope this is what you are looking for. If not, please explain in detail about your requirement, so we may be able to share a better solution with you. 
  
Regards, 
Monisha. 



MA Marco May 4, 2021 10:08 AM UTC

Hi Monisha,

again, thank you. 

I will try to explain the requirement better, just in case you come up with a better solution:

When a user drag n' drop a row, I want to update a field called priority which depends on the position of the row bound to the treegrid. At the same time, I want to update the value of the priority of all the rows which are upon the drop position of the row.

So for example, if I have five tasks, splitted in two resources:

Res 1:
     Task 1 Priority: null
     Task 2 Priority: null
     Task 3 Priority: null
Res 2:
     Task 4  Priority: null
     Task 5  Priority: null

when I move the Task 1 to the bottom (mantaining the level, which is 1)I want obviously the task to be moved under Task 5 AND I also want to update the value of priority of the upper tasks within the same resource.

So, if I move the Task 1 under the Task 5 the result should be:

Res 1:
     Task 2 Priority: null
     Task 3 Priority: null
Res 2:
     Task 4  Priority: 1
     Task 5  Priority: 2
     Task 1 Priority: 3

For my requirement, this should work also for the move operation whitin the same resource. So starting from the initial structure, if the move operation whitin the same resoulte was possible, moving the Task 1 below the Task 3 would result in this structure:

Res 1:
     Task 2 Priority: 1
     Task 3 Priority: 2
     Task 1 Priority: 3
Res 2:
     Task 4  Priority: null
     Task 5  Priority: null


I hope is sufficiently clear. 

Thank you, 
Marco





MS Monisha Sivanthilingam Syncfusion Team May 6, 2021 03:56 AM UTC

Hi Marco, 
 
We are currently working on your query. We will provide you with an update within one business day(06-05-2021). 
 
We appreciate your patience until then. 
 
Regards, 
Monisha. 



MS Monisha Sivanthilingam Syncfusion Team May 6, 2021 01:19 PM UTC

Hi Marco, 
  
Thank you for providing additional information about your requirement. We were able to understand your needs more clearly. 
  
However, once again, we would like to inform you that we cannot reorder rows within the same resource in resource view. The records can only be moved over multiple resources in the resource view. The first scenario that you mentioned would be possible, however, the second scenario where you rearranged the records within the same resource is not possible. As this scenario would cause many issues during validation of the records, hence, we have restricted such a scenario. 
  
Please contact us if you require any further assistance. 
  
Regards, 
Monisha. 



MA Marco May 6, 2021 02:31 PM UTC

Hi Monisha,

would the same be possible in Project View without any problem? If so, what is the best approach to update the data?

Thank you,
Marco


MS Monisha Sivanthilingam Syncfusion Team May 10, 2021 03:38 AM UTC

Hi Marco, 
 
Currently, we are working on your query. We will provide you with an update within one business day(May 10, 2021). 
 
We appreciate your patience until then. 
 
Regards, 
Monisha. 



MS Monisha Sivanthilingam Syncfusion Team May 10, 2021 01:01 PM UTC

Hi Marco, 
 
It is possible to move records within the same parent in Project View. However, it is not possible to move records within the same parent in Resource View. If you wish to update the priority for a task, you could set a custom column called priority and perform a sort operation on the column to rearrange the records according to priority. 
 
We have prepared a sample in resource view, in which we have included a priority field in the data. You will be able to see that when you sort the data via the priority field, the records will be rearranged in ascending order of their priorities. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 



Loader.
Up arrow icon