Question
How to change the TimeItem of parent node automatically after changing child node ?
I want to implement task grouping (similar to MS Project). If user change the start/end date of child task parent will be expanded automatically (span node).
I handled OnTimeItem_StopValueResize and OnTimeItem_StartValueResize.
Sample (simplified) source code:
OnTimeItem_StopValueResize {
GridNode node = e.TimeItem.GanttRow.GridNode;
DataRowView dataRow = node.ListItemWhenDataBound() as DataRowView;
dataRow[“startDate”] = ((DateTime)dataRow[“startDate”]).Add(e.Diff);
dataRow[“endDate”] = ((DateTime)dataRow[“endDate”]).Add(e.Diff);
if (node.ParentNode != null) {
DataRowView parentDataRow = node.ParentNode.ListItemWhenDataBound() as DataRowView;
parentDataRow[“startDate”] = dataRow[“startDate”];
}
}
After that grid data are modified correctly but Gantt item (TimeItem) is not expanded.
What should I call to refresh also Gantt area ?
I am using GTP.NET control with VS2005 (C#).
Answer
What you do in your code above is that you change the grid node datarow. If you want to change the TimeItem’s datarow you will need to do something like this:
DataRowView dataRowForTimeItem = GanttRow.FromGridNode(node.ParentNode).Layer[0][0].ListItemWhenDataBound() as DataRowView;
So to clarify: In your code I can only see a change of the Cell values not of the TimeItem, and that explains why the time item is not updated.