
32 Answers, 1 is accepted
We prepared a sample example how to populate the RadGanttView with a data from a SqlServer. In the attached zip file you can find the project plus db schema and backup which will restore the database with a sample data. Also, the connection string must be modified for the correct server name.
Please, note that the GanttView is still in CTP version and there could be some breaking changes with the official release, but they will be documented and the project will be modified. The attached sample works with the official Q1 SP1 assemblies.
Hope this helps.
George
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

I was trying to use the example you uploaded example and i got an error that says GanttViewDBEntities is missing an assembly, how to I solve that as I urgently want to save information to database
Thanks
Please, double check the connection string in the project. It must match the correct server and database.
George
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

I manage to connect to sql database but now the ganntt loads empty, where do you do your stored procedures (select,Insert,Update) as i want to perform those in my gannt
Thanks

I am connected to database but the form loads null, i have create the stored procedure on sql and imported to emdx funtion.
My SELECT Statement
SELECT
Title,Description
FROM
dbo.SqlTasks
looking forward to your response, really need your helpPlease, double check whether the database contains any records. Moreover, check the VisibleRange of the GanttView and if there are any tasks what are visible in the ranged.
George
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

I'm interested in using the GanttView control and I downloaded the example you posted here but I can't try it. I attached the .bak file to my SQL Server 2008 and then I opened it in Visual Studio 2010 and change the ConnectionString so it match my server. First it says that there is no type known as IRelation (I solve this by adding the Telerik.Windows.Data reference). After that appears a lot of errors. I show you them in the attached image.
Could you help me and guide me to the solution? Sorry if I'm missing something evident.
Regards,
Erik
With the Q2 release we introduced some breaking changes for the control which could cause the issues you faced with. Please, refer to our online documentation for more information about RadGanttView backward compatibility - http://www.telerik.com/help/silverlight/radganttview-backward-compatibility.html
Hope this helps.
George
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Is there any updated versión of this simple for the 2013 version of Silverligth?
I mostly get issues in the SQLTask.cs here:
private IList relations;
IList IGanttTask.Relations
{
get
{
if (this.relations == null)
{
using (var context = new GanttViewDBEntities())
{
this.relations = context.SqlTasks.Single(task => task.SqlTaskId == this.SqlTaskId).SqlRelations.ToList();
}
}
return this.relations;
}
}
I really would appreciate your help, on this matter.
I'm sending you attached a recently made sample project which demonstrates how to use RadGanttView with a DB as source. In the web project is also a sql script included which should help you to create the basic DB table which is needed for this example.
I hope this helps.
Regards,
Ventzi
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Thanks for this project. It clarifies a bit the way to store the data in a database. It seems there is an issue when I try to move a task on upper level or lower level (slide it up or down with the mouse). Silverlight crashes when it renders the page. Would it be possible to have a look?
More generally how to you save the order of tasks in the database and how you retried them in the correct order to display them ?
And is it possible later on to export Telerik tasks into Microsoft Project?
I want to use this Telerik control in order to offer to our user an easy tool to manage their tasks and to avoid the complexity of
Microsoft Project.
Thanks
Sebastien
Can you send us a video of the exception? What type of exception is it? This will be helpful in order to reproduce the problem.
According to the saving/retrieving the tasks - they are retrieved in the way they are saved and this is automatically handled by EF. Note that the tasks are retrieved in a time range in the GanttViewDomainService.
Currently only importing from MS project is available for RadGanttView - example of that can be found here. Exporting to MS Project is not implemented yet. It is logged as future request here and you can vote for it. If it gets enough clients request, we will review it for our upcoming development.
I am looking forward to your reply.
Regards,
George
Telerik

Thanks for your help. I did a little video that shows you the issue using Microsoft Expression Encoder. (Replace extension .jpg by .xesc and it should work). Hope you will be able to read it.
The video start by showing the db structure. Then the project itself that is a copy from Telerik example with a Master page.
I try to move up a task and the Gantt control crash.
Best regards
Sebastien
We managed to reproduce the issue with the example - it was caused by an improvement with the implementation of the GanttView control introduced after the example was posted in this thread. What you need to do in order to fix it is would be to also inherit from the IEditableHierarchical interface in the SqlTask class:
public
partial
class
SqlTask : IGanttTask, IMilestone, ISummary, IDependant, IEditableHierarchical
{
...
}
Afterwards you have to implement the two methods coming from the interface the following way:
public
void
InsertChildAtIndex(
object
item,
int
index)
{
var tasks = (ObservableCollection<SqlTask>)
this
.Children;
var ganttTask = item
as
SqlTask;
if
(ganttTask !=
null
&& index <= tasks.Count)
{
tasks.Insert(index, ganttTask);
var sqlParentChildTask =
new
SqlParentChildTask() { ParentTaskId =
this
.Id, ChildTaskId = ganttTask.Id };
GanttViewRepository.Context.SqlParentChildTasks.Add(sqlParentChildTask);
}
}
public
void
Remove(
object
item)
{
var tasks = (ObservableCollection<SqlTask>)
this
.Children;
var ganttItem = item
as
SqlTask;
if
(ganttItem !=
null
)
{
tasks.Remove(ganttItem);
var sqlParentChildTask = GanttViewRepository.Context.SqlParentChildTasks.FirstOrDefault(ct => ct.ChildTaskId == ganttItem.Id);
if
(sqlParentChildTask !=
null
)
{
GanttViewRepository.Context.SqlParentChildTasks.Remove(sqlParentChildTask);
}
}
}
Please give it a try and let me know if it resolves the issue.
Hope this helps. I have also updated your Telerik points for your involvement.
Regards,
Kalin
Telerik

Thanks a lot for the fast reply. I tested it this morning and it works fine. I noticed one more issue that I can reproduce on the sample project. If you add more than one task in a row(not a child) , only the first task added is saved in the database.
Regards
Sebastien
Thanks for your feedback - I have managed to reproduce the issue. In order to fix it you will have to modify the InsertTask method of the GanttViewModel class the following way:
internal
bool
InsertTask(SqlTask task)
{
if
(!
this
.IsChild(task,
this
.tasks))
{
this
.tasks.Add(task);
if
(task.EntityState == EntityState.Detached)
{
GanttViewRepository.Context.SqlTasks.Add(task);
return
true
;
}
}
return
false
;
}
Hope this helps.
Regards,
Kalin
Telerik

Greetings from Stockholm
Sebastien
I'm glad it helped. If you have any other question or concerns, please do not hesitate to contact us.
Regards,
Kalin
Telerik

I’m facing a new problem link to dependency between tasks. Prior to be saved all new tasks added have the same id = 0. If I add 3 new tasks in a row with dependency between them, then only the first task added will keep its dependency.
The work around is to save automatically after adding a new task and after all manipulation in the UI. I tried to implement the events ManipulationCompleted, ManipulationDelta, ManipulationStarted, I got the error message: Failed to assign to property 'System.Windows.UIElement.ManipulationCompleted'.
Best regards
Sebastien
I managed to reproduce the issue. After further investigation it appears that the easiest solution in this case would be to Save after each new Task is added. You will need to replace the InsertTast method with the following one:
internal
bool
InsertTask(SqlTask task)
{
if
(!
this
.IsChild(task,
this
.tasks))
{
this
.tasks.Add(task);
if
(task.EntityState == EntityState.Detached || task.EntityState == EntityState.New)
{
GanttViewRepository.Context.SqlTasks.Add(task);
GanttViewRepository.SaveData();
return
true
;
}
}
return
false
;
}
However we will think of the better solution later on when possible.
Please test and let me know if this works for you.
Regards,
Kalin
Telerik

I also moved into that direction and auto-save all new tasks. Your code works fine. What annoy me with this solution is that users can drag and drop dependencies between tasks in the UI. There is no event handler to catch those changes, so a save button should remained. It will bring confusion to user that new tasks are automatically saved but new dependencies are not. For all other action like moving a task, changing the title etc… the event handler TaskEdited works fine.
Have a good day
Sebastien
When modifying the dependencies between the Tasks in the UI the AddDependency method in the SqlTask class is called - you can save there. You might need to save in RemoveDependency method as well.
Please test it and let me know if it works.
Regards,
Kalin
Telerik

Yes it works. My problem is solved. No save button and all actions are directly saved in the database.
Thanks
Sebastien
I'm glad it helped. If you have any further questions or concerns, please let us know.
Regards,
Kalin
Telerik

Hi Kalin,
I'm coming back to the forum with a new question regarding import from Microsoft Project. We would like to have the possibility to import directly from Microsoft Project tasks into our Sql database. On Telerik demo website there is this example :
http://demos.telerik.com/silverlight/#GanttView/Import
This example show a method that convert XML from MSProject into a task list that is an ObservableCollection<GanttTask>();
Would you have a method to convert XML from MSProject into an ObservableCollection<SqlTask> or would you have a method to convert GanttTask into SqlTask ?
Best regards
Sebastien
In the mentioned example in MsProjectImportHelper we are generating GanttTasks from the provided xml. Similarly we can generate SqlTask instead of GanttTask as the SqlTask is also an IGanttTask.We should add the missing UniqueId property in the SqlTask class.
If you wish to convert each GanttTask generated from the MsProjectImportHelper.GetMsTasks() to SqlTask you can use something like that:
private
static
Dictionary<GanttTask, SqlTask> generatedTasks =
new
Dictionary<GanttTask, SqlTask>();
public
SqlTask ConvertGanttTaskToSqlTask(GanttTask gTask)
{
var sTask =
new
SqlTask()
{
Start = gTask.Start,
End = gTask.End,
Title = gTask.Title,
Deadline = gTask.Deadline,
UniqueId = gTask.UniqueId,
Description = gTask.Description,
Duration = gTask.Duration,
};
var currentSqlTaskChildTasks = (ObservableCollection<SqlTask>)sTask.Children;
foreach
(var childGanttTask
in
gTask.Children)
{
currentSqlTaskChildTasks.Add(
this
.ConvertGanttTaskToSqlTask((GanttTask)childGanttTask));
}
sTask.Children = currentSqlTaskChildTasks;
generatedTasks.Add(gTask, sTask);
return
sTask;
}
//After all SqlTasks are Generated we should add their dependencies.
public
void
AddSqlDependenciesToGeneratedSqlTask(GanttTask gTask)
{
var sTask = generatedTasks[gTask];
foreach
(var dependency
in
gTask.Dependencies)
{
sTask.Dependencies.Add(
new
SqlDependency() { FromTask = generatedTasks[(GanttTask)dependency.FromTask], DependencyType = dependency.Type });
}
}
Hope this helps.
Regards,
Polya
Telerik
See What's Next in App Development. Register for TelerikNEXT.

Hello Polya,
Thanks for the very quick reply. We will have a look at this solution.
Best regards
Sebastien

Hello Polya, my name is Leonel, I'm working with Sebastien in the same project.
Sometimes when I change dates or add a child task (for example), silverlight exception are thrown, (see attached file), how can I debug that to see errors?
Are you using Internet Explorer to debug the Silverlight Application. There might be several things that can help you isolate the issue. You can check this article http://www.codeproject.com/Articles/238781/Why-Visual-Studio-Debugger-is-not-working-for-my-S for more information on how to debug Silverlight applications.
Also if you can isolate the issue in a sample project you can open a support ticket and attach it there so we can investigate it further.
Regards,
Polya
Telerik

Seems like there is not too much info over the Net regarding Gantt and SQL. In my case a have a tree column (should be task and sub task) but how do I set bind them to SQL table? There's only option to set binding for tree column.
<telerik:RadGanttView.Columns><telerik:TreeColumnDefinition MemberBinding="{Binding TaskId}" Header="Tasks" IsFrozenColumn="True"/><telerik:ColumnDefinition MemberBinding="{Binding StartTime}" Header="Start" /><telerik:ColumnDefinition MemberBinding="{Binding EndTime}" Header="End" /></telerik:RadGanttView.Columns>
Can someone please upload working WPF project.

Can you please take a look at the ConnectToDatabase GanttView SDK example and let me know if it helps?
Regards,
Martin Ivanov
Progress Telerik