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

GanttViewDataItem.SetValue() to collumn

1 Answer 44 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Nikola
Top achievements
Rank 1
Nikola asked on 11 Aug 2014, 01:38 PM
hello,

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";

this.radGanttView.GanttViewElement.Columns.Add(titleColumn);
this.radGanttView.GanttViewElement.Columns.Add(startColumn);
this.radGanttView.GanttViewElement.Columns.Add(endColumn);
this.radGanttView.GanttViewElement.Columns.Add(dauerColumn);
this.radGanttView.GanttViewElement.Columns.Add(myColumn);
 
 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:

this.radGanttView.Items.Add(item);


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





1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 14 Aug 2014, 09:56 AM
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.

Regards,
George
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.
 
Tags
GanttView
Asked by
Nikola
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or