cancel
Showing results for 
Search instead for 
Did you mean: 

SapUi5 Gantt Chart - renders incorrect data after moving nodes around in underlying data structure

0 Kudos

Hi,

I'm trying to implement drag and drop to change the parent task of a task sub tree. My data structure is hierarchical ProjectNodes where each node has a collection "children".

On the shapeDrop event I am altering the data hierarchy as required, and the data structure looks right, but the Gantt Chart renders the wrong information - it basically renders the wrong child elements. Here's an example of what's happening -

1. I start with a top-level task, "Task A" with 3 children, "Task X", "Task Y", "Task Z".

2. I drag Task Y on to Task X to change parent from A to X - I modify the data so that A has children X, Z and X has child Y.

3. I rebind (found this in one of the examples):

var gantt = evt.getParameter("sourceGanttChart");

var table = gantt.getTable();

model.setData(model.getData());

table.bindRows({ path: 'plandata>/data', parameters: { arrayNames: [ 'children' ] } });

4. Gantt Chart displays "Task A" with 2 children, "Task X" and "Task Y". "Task X" has child "Task Y". Basically I have "Task Y" listed in 2 positions, but "Task Z" has not been displayed. My data definitely only has 2 children of "A", and they are "X and Z".

My question is how do I rebind the Gantt chart with table to a model that has structurally changed?

More info:

I'm using SapUi5 V1.61.2, maybe it's fixed - I'll check that.

My models are set at the view level (I saw an answer that suggested that models should be bound at the GanttContainer level, not the Chart level, does this advice also apply to higher level models).

I'm using JSON models for my solution.

Thanks in advance for any help or advice.

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Turns out that this wasn't a problem in the Gantt chart on this occasion. I discovered that after my async handler had rebound the tree and exited, my underlying data object changed, and the offending node was re-inserted. I couldn't work out what was changing it, because my code should be waiting on events.

Long story short, I'd allowed my logic to flow into another async update routine, whose effect was to setProperty on a precalculated path, with the actual node object. So it was an async/program flow issue, not a Gantt chart issue.