Roel
Roel

Reputation: 48

AnyChart 8.1.0 - Resource Gantt - Move periods from one resource to another

I am using the AnyChart 8.1.0 resource Gantt (anychart.ganttResource()) to show and edit planned data (car reservations). I can edit / move a reservation horizontally to change the time / period of a reservation and also drag the start and/or enddate. But I would like to move a reservation from one car (row) to another - very similar to moving a task from one person to another. Is that possible - and how?

Thanks! Roel

Upvotes: 0

Views: 134

Answers (2)

Roel
Roel

Reputation: 48

That's too bad. I can manipulate the tree - even one period, using this code to delete and add a period. You can update a period as well, code should be similar.

function deletePeriod( pItemId, pPeriodId ){
  var item = treeData.search("id", pItemId);
  var periods = item.get("periods")
  var i = periods.findIndex(function(e){ return e.id == pPeriodId; });
  periods.splice(i,1);
  item.set('periods', periods);
  treeData.addChildAt( item, treeData.indexOfChild(item) );
}

and

function addPeriod( pItemId, pPeriodId, start, end){
  var period = {
    "id": pPeriodId,
    "start": start,
    "end": end,
    "name": "Whatever name you want"
  };

  var item = treeData.search("id", pItemId);
  var periods = item.get("periods");
  periods.push(period);
  item.set('periods', periods);
  treeData.addChildAt( item, treeData.indexOfChild(item) );
}

Upvotes: 0

Anja R
Anja R

Reputation: 88

I'm having the same issue, and as far as I can see you can use

    tree.listen("treeItemMove", function (e) {
                // do your stuff
                });

Unfortunally, I think this will only work, if you only have one reservation in each row. If you have more than one, all reservations will be moved. So far I haven't found a solution to get one reservation and move it to another row. But I hope it may help you in the rigth direction..

EDIT:

I have contacted Anychart support and asked if there is a way to move one period from one (child-) row and create a new row under another parent?

Here is the answer:

the current version of AnyGantt 8.1.0 doesn't provide this feature as an out-of-the-box or even with the extra code. But you can modify the dataTree from the code as you need. This provides full control under the data, but without mouse interactivity.

Upvotes: 1

Related Questions