Hi,
If I know the Id of a task (the guid id), how do I find that task and set it to be the ActiveTask on the UltraGanttView?
Normally I'd do a linq statment on the task collection, but I can't find a task collection to get the task from in the gantt, the calendar info or even by going to the underlying grid (as the object type in the grid is internal). I suspect I'm missing something obvious here!
Thanks, Tom
Thanks Hristo
I ran your code though a code converter (as our UI is VB) but it didn't work, probably the fault of the code converter. For anyone else reading this thread this was the VB code I used in the end which seems to work well:
Public Shared Function FindTaskByID(tasks As TasksCollection, id As Guid) As Infragistics.Win.UltraWinSchedule.Task
If tasks Is Nothing Then Return Nothing
For Each task In tasks
'Is this the matching task?
If task.Id = id Then Return task
'Recurse the child tasks
Dim match = FindTaskByID(task.Tasks, id)
If match IsNot Nothing Then Return match
Next
Return Nothing
End Function
Hello,
If the task that you are trying to find is a child task then you should search into the task tree with some algorithm for searching into tree. Here is one simple implementation of such algorithm applied to your particular scenario:
private Infragistics.Win.UltraWinSchedule.Task FindTaskByID(TasksCollection tasks, Guid id)
{
if (tasks == null)
return null;
Infragistics.Win.UltraWinSchedule.Task searchedTask = tasks.FirstOrDefault<Infragistics.Win.UltraWinSchedule.Task>(t => t.Id.Equals(id)) as Infragistics.Win.UltraWinSchedule.Task;
if (searchedTask == null)
int count = 0;
while (count < tasks.Count && searchedTask == null)
searchedTask = FindTaskByID(tasks[count].Tasks, id);
count++;
}
return searchedTask;
else
Please let me know if you have any further questions
Hi
Sorry, forgot to say I'd tried that - the problem with that collection is that it only contains the top level nodes, so if the task I'm trying to find is a child of one of those tasks the linq statement will return no records. Is there a property that returns the flattened out collection of all tasks and child tasks or do I need to write some soft of recursive routine to walk the tree?
Hello ,
You could use Tasks collection of corresponding UltraCalendarInfo, more information about this collection you will find on the following link:
http://help.infragistics.com/Help/Doc/WinForms/2014.1/CLR4.0/html/Infragistics4.Win.UltraWinSchedule.v14.1~Infragistics.Win.UltraWinSchedule.UltraCalendarInfo~Tasks.html
so you could use linq statement like following:
ultraCalendarInfo1.Tasks.FirstOrDefault<Infragistics.Win.UltraWinSchedule.Task>(t => t.Id == yourId);
Please let me know if you have any further questions.