Hello
How to order the tasks in winganttview after loading from SQL database?
Regards
Essna
Hello Essna,
The UltraGanttView will by default show its tasks in the order that they’ve been added to the Tasks collection of the UltraCalendarInfo of the gantt view. If that order is not the order you want you can change it using the SortedFields collection of the Tasks. For example the following line will sort the tasks based on their name in descending order:
ultraCalendarInfo1.Tasks.SortedFields.Add(SortableTaskField.Name, SortOrder.Descending);
If you want to know more about the sorting capabilities of the WinGanttView you should visit this link:
http://help.infragistics.com/NetAdvantage/WinForms/2013.1/CLR4.0/?page=WinGanttView_WinGanttView_Sorting.html
Please let me know if you have any additional questions.
Thank you for the answer, but I use DataBindingsForTasks to bind my winganttview to the SQL server. Also using SortedFields, is not possible to order the tasks by their original sequence. I want to create tasks in this order
- Task John
- Task Andrew
- Task Dave
Next time, when I load these three tasks from the server, I want to see the same order. Now the order is different each time. Is this a bug ? Please provide solution.
Thank you
Can you please clarify the exact column/property by which you want to order your tasks, also the reason why you shouldn’t use SortedFields. If your custom order criteria is not part of the SortableTaskField enumeration you could use ICompare interface to implement your custom logic. This is very flexible way to sort your task in the exact order you want. To do that you have to set the SortedFields.Comparer property to an instance of a class which implements ICompare<Task>. After that you need to add a new sorted field with SortableTaskField.Custom:
this.ultraCalendarInfo1.Tasks.SortedFields.Comparer = new CustomComparer(); this.ultraCalendarInfo1.Tasks.SortedFields.Add(SortableTaskField.Custom, SortOrder.Ascending);
I hope this is what you are looking for.
I am waiting for your response.
Hello Dimitar,
It is very easy to reproduce this bug. Just create 3 tasks and save it in database. Next time, when you run application and load these tasks, the order will be different. For example. I created the tasks
After loading from database, the order is:
Please provide a workaround for this bug.
I tried to reproduce your issue using Volume 13.1 (13.1.20131.2079) and everything works as expected. I have a Tasks database with three entries ordered (this is the order in which I have entered those records):
-Task John
-Task Andrew
-Task Dave
When I load the tasks, they are displayed in that exact order in the UltraGanttView. Please see the following YouTube video, which shows that everything is working correctly on my machine:
http://youtu.be/MSWLzuXOV-U
It seem that your query to database reorders your data, or you have applied some sorting to GanttView. So please be sure that you are using mentioned version of Infragistics, also check your query if there is statement for ordering and your code to see if you have applied some sorting to GanttView.
Don’t hesitate to ask any additional questions you may have.
Dimitar,
Did you read the steps to reproduce from my post. There are only two steps. Where is the first step in your video ??? How were set the tasks in database through wingantview control ? Do you think, that the loop, from your sample will works with 50 projects and 1000 tasks per project. Where are other tasks fields like AllProperties, Constraint and etc.
I am just checking about the progress of this issue. Let me know If you need my further assistance on this issue.
Thank you for using Infragistics Components.
Hello,
I am just checking about the progress of this issue. Let me know If you need any further assistance on this issue?
Hello,
In order to reproduce this issue I’ve created the attached sample, where instead of SQL server I am using Local Database (so I have connection string, data adapters and everything needed to connect to SQL server). Also I’ve captured small video of how this works on my machine. So you are able to see what I am doing and could let me know if I am missing something.
Please notice that when I am creating new task, I’m right clicking on the empty area of grid part of the GanttView. If I right click on an existing task, the new added task will appears above the clicked task in the GanttView, and it will be recorder in the database at the bottom of the DataTable. So next time when I run the application tasks will appears in the same order as they comes from the database, and this will be different of those which we saw in the GanttView before. We cannot change this since DataTable object doesn’t support InsertAt(index) method and the only way to add new row is on the bottom of the DataTable object. If this is your issue then I suggest you to add a column in your data base which will holds position on which task must be initially displayed , and when you retrieve your data to order your records on this column.
Please let me know if you have any further questions or if I am missing something.
Obviously you are not able to help me. The problem is not in the version. You could reproduce it with your new version 13.2. Will be better if you read your own documentation, how to bind calendarInfo http://help.infragistics.com/Help/Doc/WinForms/2013.1/CLR4.0/html/WinGanttView_DataBinding_Support_for_WinGanttView.html
I am disappointed by your sample. Your table doesn't have a primary/unique key and will be very interesting for me to see how you will update and delete specific task. Do not feel obliged to answer, I found solution of my problem.
-Essna