This is a migrated thread and some comments may be shown as answers.

Problems with custom gantt provider

9 Answers 230 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 19 Feb 2015, 02:10 PM
Hi,

I implemented a custom gantt provider just like in the code library for a custom gantt provider. This worked perfectly well. But when I try to set the end date of a child task after the end date of the parent task, the update of the tasks do work but the task aren't shown any more inside the gantt control. I do have the same problem if I try to delete or to add the child task of my root element -> No tasks are shown inside the gantt control anymore.

My second problem is that I want to set a information message inside a label if inserting, updating or deleting of a task is successful or not. But the text of the label doesn't change wether I place the label inside the same radajaxpanel or place it outside of the radajaxpanel which contains the gantt control because changing the tasks does not trigger a full postback. Can someone help me with my problems? Thanks.

Regards,
Michael

9 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 23 Feb 2015, 11:22 AM
Hi,

The sample code from the code library is working fine on our end, regardless of the operation performed. If your implementation differs in any way from the sample code, please open a support ticket and attach a runnable sample project, so that we can inspect it locally.

As for the second issue, by default the Gantt control uses Callbacks to perform the CRUD operations, and not postbacks. That's why the AjaxPanels aren't triggering. If you want to trigger a postback on each operation, just set the Server-side event for this operation. For instance if you want deleting a task to trigger a postback, you will have:
<telerik:RadGantt ID="RadGantt1" runat="server"
    SelectedView="WeekView"
    OnTaskDelete="RadGantt1_TaskDelete">
</telerik:RadGantt>


Regards,
Bozhidar
Telerik
0
Michael
Top achievements
Rank 1
answered on 23 Feb 2015, 11:57 AM
Hi Bozhidar,

after my post I've tried the example from the code library and sadly it works as expected ;-). So it seems that something is wrong with my implementation which I have to inspect. But as far as I recognized the only difference is that I use NHibernate instead of the Entity-Framework. But I think this can't be the reason for my problems. If I don't find a solution I will send you a runnable example.

As for the second problem, I've already attached the server-side for the crud operations. This works well. But my problem is that then the gantt chart control loses the selections of the user e.g. for the selected gantt view, more preciesly the gantt chart control is reset completely which is quite annyoing for the user. Is there a option to keep the state of the gantt chart control even with a full postback? Thank you.

Regards,
Michael
0
Bozhidar
Telerik team
answered on 24 Feb 2015, 08:50 AM
Hello,

Currently there isn't a way for the gantt to keep track of its selected state out of the box. However you can use some javascript code to implement it yourself. I've attached a small sample page where I demonstrate how it can be done.

Regards,
Bozhidar
Telerik
0
Felix
Top achievements
Rank 1
answered on 10 Mar 2015, 12:31 PM
Hello,

I'm using a custom gantt provider. But I don't want to insert, update, delete any changes of the tasks inside the gantt control immediatly but when the user clicks a save button. So I store the tasks inside the session and give every new task a temporary Id insde the TaskInsert-Mehtod of the Custom gantt provider. When the user clicks save the task are made persistent and inside the GetTasks-Event I want to set the Id how it is inside the database and refresh the list with the tasks inside the gantt control. But this doesn't work for some reason. Only setting the Id inside the Insert-method seems to work. Is this bug already known or is this a wished behaviour?. Thanks.

Regards,
Felix
0
Hristo Valyavicharski
Telerik team
answered on 13 Mar 2015, 10:01 AM
Okay, if you don't want to persist the challenges set the second parameter to false:

  protected void Page_Load(object sender, EventArgs e)
    {
        RadGantt1.Provider = new XmlGanttProvider(Server.MapPath("Tasks.xml"), false);
    }



Regards,
Hristo Valyavicharski
Telerik
0
Felix
Top achievements
Rank 1
answered on 13 Mar 2015, 10:33 AM
Hi Hristo,

thanks for your answer. But I don't use the XMLGanttProvider but a GanttCustomProvider which inherits from GanttProviderBase. The only thing I want to do is to replace my temporary Ids through the Ids of the tasks, which are assigned by and stored inside the database after the user clicks the save-button inside my GetTasks-method of my GanttCustomProvider like this:

public class GanttCustomProvider : GanttProviderBase, IGanttCustomProvider
    {
public override ITaskFactory TaskFactory
        {
            get { return new CustomGanttTaskFactory(); }
        }
 
        public override List<ITask> GetTasks()
        {
   var tasks = new List<ITask>();
             
            //Load projectElmentDtos from the session
            foreach (var task in GetTasksFromDatabase())
            {
                    tasks.Add(new CustomTask
                    {
                        ID = task.Id,
                        Title = task.Title,
                        ParentID = task.ParentId,
                        OrderID = task.OrderId,
                        Start = task.StartDate,
                        End = task.EndDate,
                        Summary = task.Summary,
                        Expanded =task.Expanded,
                        PercentComplete = Convert.ToDecimal(task.PercentComplete),
                        TaskDuration = task.TaskDuration
                    });
                }
            }
            return tasks;
        }
 
  public override ITask InsertTask(ITask task)
        {
           //Set a temporary random guid because if an update to a non-persistent ganttTask happens
                //the object has to be indentified
                task.ID = Guid.NewGuid();
                GanttTask ganttTask = ToGanttTask(task);
                InsertTaskToDatabase(ganttTask);
        }
 
 
        public override List<IDependency> GetDependencies()
        {
           var dependencies = new List<IDependency>();
            foreach (var dependency in GetDependenciesFromDatabase())
            {
              
                    dependencies.Add(new Dependency
                    {
                        ID = dependency.Id,
                        PredecessorID = dependency.PredecessorId,
                        SuccessorID = dependency.SuccessorId,
                        Type = (DependencyType)dependency.Type
                    });
                }
               
            }
    return dependencies;
        }
}
 
 public class CustomGanttTaskFactory : ITaskFactory
    {
        Task ITaskFactory.CreateTask()
        {
            return new CustomTask();
        }
    }
 
public class CustomTask : Task
    {
        public CustomTask() : base(){}
 
        public double TaskDuration
        {
            get { return (double)(ViewState["TaskDuration"] ?? 0.0); }
            set { ViewState["TaskDuration"] = value; }
        }
 
        protected override IDictionary<string, object> GetSerializationData()
        {
            var dict = base.GetSerializationData();
            dict["TaskDuration"] = TaskDuration.ToString(CultureInfo.InvariantCulture);
            return dict;
        }
 
        public override void LoadFromDictionary(IDictionary values)
        {
            base.LoadFromDictionary(values);
 
            if (values["TaskDuration"] != null)
                TaskDuration = Double.Parse(values["TaskDuration"].ToString());
        }

But if I set the Ids inside "public override List<ITask> GetTasks()"-method or  "public override List<IDependency> GetDependencies()-method the ids inside the list with the tasks are not replaced. Hope this explanation is sufficient. Thanks.

Regards,
Felix
0
Hristo Valyavicharski
Telerik team
answered on 18 Mar 2015, 12:05 PM
Hi Felix,

Yes the Custom Provider does not allow you to disable changes persistence, that's why you will have to go with your approach.  What if you create and return new tasks collection in the GetTasks(), populated from the existing one. New DTO. Does it help?

Regards,
Hristo Valyavicharski
Telerik
0
Felix
Top achievements
Rank 1
answered on 18 Mar 2015, 01:06 PM
Hi Hrsito,

if I'm not totally wrong your suggestion is how I already try to update the list with the tasks inside the gantt control. The user adds new tasks. This tasks are stored inside the session with a temporary id. When the user clicks save these tasks are save to the database and get an id assigned by the database. After that the GetTask()-method is called which gets the persistent tasks and adds them to the var tasks = new List<ITask>() and returns the list. The problem is that the temporary ids which are still inside the gantt control aren't replaced by the persistent ids from the database. On the other way round setting the id inside the InsertTask()-method is possible.
But it seems that the call of the GetTasks()-method after I clicked the event triggered by the save-button seems to be to late because if I load the already existing tasks from the database initially the ids are set the right way.

Regards,
Felix
0
Felix
Top achievements
Rank 1
answered on 12 May 2015, 06:40 AM

Hello,

is it somehow possible to get all the child tasks e.g. inside the UpdateTask-method of my GanttCustomProvider. Unfortunately if I call "task.Tasks" the collection is empty every time. The only possibility I know how to get the child tasks is to call the Databind()-method of the RadGrid at the code behind, which is no option for me. But there musst be another possibility to get all the child tasks of a updated task or am I wrong with that? Thanks.

Regards,

Felix

Tags
Gantt
Asked by
Michael
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Michael
Top achievements
Rank 1
Felix
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or