This is a migrated thread and some comments may be shown as answers.
data bound
3 Answers 38 Views
This is a migrated thread and some comments may be shown as answers.
Sergey
Top achievements
Rank 1
Sergey asked on 09 Jun 2014, 07:37 AM
Hello.

Can you help me with an example of databinding GanttViewDataItem to not radproperty. like textbox.Text property?

Thank you.

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 11 Jun 2014, 03:08 PM
Hi Sergey,

Thank you for writing.

You can bind a GanttViewDataItem to a textbox by using simple data binding. For example:
GanttViewDataItem subitem11 = new GanttViewDataItem();
subitem11.Title = "Sub-task.1.1 title";
 
textBox1.DataBindings.Add("Text", subitem11, "Title", true, DataSourceUpdateMode.OnPropertyChanged);

Let me know if you have additional questions.

Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Sergey
Top achievements
Rank 1
answered on 11 Jun 2014, 04:29 PM
Dimitar thank you for your answer.

Here is one more question in this context

I've trying to bind  GanttViewDataItem  to entity framework ENTITY and cant find way how to do it.

Trying this i got a problem, moving edge of task (changing dates) didn't fire events:

 void GanttViewElement_ItemValidated(object sender, GanttViewItemValidatedEventArgs e)
        {
            if (e.Item.Tag.GetType().BaseType.Name == "Task")
            {
                ((Task)e.Item.Tag).tStartDate = e.Item.Start;
            }
            if (e.Item.Tag.GetType().BaseType.Name == "Project")
            {
                ((Project)e.Item.Tag).pStartDate = e.Item.Start;
            }

            db.SaveChanges();
          
        }

        private void GanttViewElement_ItemEdited(object sender, GanttViewItemEditedEventArgs e)
        {
            if (e.Item.Tag.GetType().BaseType.Name == "Task")
            {
                ((Task)e.Item.Tag).tStartDate = e.Item.Start;
            }
            if (e.Item.Tag.GetType().BaseType.Name == "Project")
            {
                ((Project)e.Item.Tag).pStartDate = e.Item.Start;
            }

            db.SaveChanges();
        }

But it works well when i'm changing dates in columns. Whats the problem?



0
Dimitar
Telerik team
answered on 16 Jun 2014, 10:56 AM
Hi Sergey,

Thank you for writing back.

In this case you can override the default gantt view behavior and invoke the ItemValidated method manually when an item is resized. For example you can use the following behavior:
public class CustomGanttBehavior : BaseGanttViewBehavior
{
    public CustomGanttBehavior()
    {
 
    }
    protected override void ProcessMouseUpWhenResizingTask(GanttGraphicalViewBaseTaskElement element, MouseEventArgs e)
    {
        base.ProcessMouseUpWhenResizingTask(element, e);
 
        MethodInfo method = typeof(RadGanttViewElement).GetMethod("OnItemValidated", BindingFlags.Instance | BindingFlags.NonPublic);
        GanttViewItemValidatedEventArgs args;
        if (element.Parent is GanttViewTaskItemElement)
        {
            args = new GanttViewItemValidatedEventArgs(((GanttViewTaskItemElement)element.Parent).Data, null);
        }
        else
        {
            args = new GanttViewItemValidatedEventArgs(((GanttViewSummaryItemElement)element.Parent).Data, null);
        }
 
        method.Invoke(this.GanttViewElement, new object[] { args });
    }
}
 
This class can be used as follows:
this.radGanttView1.GanttViewBehavior = new CustomGanttBehavior();

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Asked by
Sergey
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Sergey
Top achievements
Rank 1
Share this question
or