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
Hello,
I am just checking about the progress of this issue. Let me know If you need any further assistance on this issue?
Thank you for using Infragistics Components.
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.
Dimitar,
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
I am just checking about the progress of this issue. Let me know If you need my further assistance on this issue.
Could you please let me know the exact version of Infragistics that you are using.
I modified my sample so that it can now create, save, load and delete tasks. It is still working as expected. The tasks are saved in the database in the order they were created and that is the order they are loaded into the grid. I’ve attached my sample, so you can take a look at it. On the following link you will find video, which shows how my sample works:
http://youtu.be/K-EPJxBqhbw
So I still believe that somewhere in your code, there is part that reorders the tasks and that is the reason for your issue. If you are unable to find it you could try to create a field in your database, which is filled by default with the exact time when the task was created and then to sort the tasks based on that criteria.