GanttViewDataItem.SetValue() to collumn

2 posts, 0 answers
  1. Nikola
    Nikola avatar
    3 posts
    Member since:
    Aug 2014

    Posted 11 Aug 2014 Link to this post


    Im generating my GanttViewDataItems per code. I will not set up a DataSet for it. Everything works fine, but I need that the item has an extra property for an extra TextViewCollumn.

    I have set up my cols:

    GanttViewTextViewColumn titleColumn = new GanttViewTextViewColumn("Title");
    GanttViewTextViewColumn startColumn = new GanttViewTextViewColumn("Start");
    GanttViewTextViewColumn endColumn = new GanttViewTextViewColumn("End");
    GanttViewTextViewColumn dauerColumn = new GanttViewTextViewColumn("Progress");
    GanttViewTextViewColumn myColumn = new GanttViewTextViewColumn("myValue");

    titleColumn.HeaderText = "title";
    startColumn.HeaderText = "title";
    endColumn.HeaderText = "title";
    dauerColumn.HeaderText = "title";
    planmengeColumn.HeaderText = "myvalue";

     Then i create my Items ( I loop them outside):

    GanttViewDataItem item = new GanttViewDataItem();
    item.Tag = value1.ToString();
    item.Start = value2.ToDateTime();
    item.End = value3.ToDateTime();
    item.Title = value4.ToString();
    item.Progress = value5.ToInt16();

    myRadObject plan = new myRadObject();
    plan.myValue = 121212;
    plan.SetValue(myRadObject.myProperty, plan.myValue);
    item.BindProperty(myRadObject.myProperty, plan, myRadObject.myProperty, PropertyBindingOptions.OneWay); 

     I created a inner class for RadObject (myRadObject)

     internal class myRadObject : RadObject
    public static RadProperty myProperty = RadProperty.Register("myValue", typeof(decimal), typeof(myRadObject),
    new RadElementPropertyMetadata("", ElementPropertyOptions.None));

    public decimal val
    get {return (decimal)this.GetValue(myProperty); }

    set { this.SetValue(myProperty, value); }

     Add to GanttView:


     The problem is that it will not display the items in the "myValue" collumn, the rest works great!

  2. George
    George avatar
    500 posts

    Posted 14 Aug 2014 Link to this post

    Hello Nikola,

    Thank you for writing.

    This approach would not work since the GanttViewDataItem has no such property. Moreover, RadObject is mostly used for UI components and the DependencyProperties are used for the theming mechanism. I would highly recommend you to use simple CLR properties along with the INotifyPropertyChanged interface for your types. You should also create a derivative of GanttViewDataItem which will have the needed CLR properties.

    Let me know if you have further questions.

    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