data bound

4 posts, 0 answers
  1. Sergey
    Sergey avatar
    2 posts
    Member since:
    Jun 2014

    Posted 09 Jun 2014 Link to this post

    Hello.

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

    Thank you.
  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 11 Jun 2014 Link to this post

    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.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Sergey
    Sergey avatar
    2 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 in reply to Dimitar Link to this post

    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?



  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 16 Jun 2014 Link to this post

    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.
     
Back to Top