Hi,
I am trying to populate the UltraGanttView and I'm not getting information to bind correctly. Basically, I'm using a DataSet named VendorRepo with two DataTables called theVendors and theTasks. The DataSet is updated by a message received by a socket listener on a separate thread. I suspect the problem could lie in either 1) I'm not binding the data correctly because I've missed some setup assumptions from the documentation, or 2) maybe the separate update thread is triggering a data change event on the wrong thread? I'd like to rule out any problems with the first issue with this post.
I'm posting a printout of my dataset, the code for the dataset, and then the form load event.
Here is a print out of the data when I run the code, which looks like I expect it to. No exceptions are thrown at all, but nothing shows up in the task list or in the timeline:
Number of vendors captured is: 1
--------------------------------------------
Vendors DataTable Contents: Record 0
VendorGuid: 00000000-0000-0000-0000-000000000000
VendorID: FF:00:00:01
VendorName: ACME Vending
VendorstartTime: 1/1/0001 12:00:00 AM
Number of Transactions captured is: 2
Transactions DataTable Contents, Record :0
TransactionGuid: 00000000-0000-0000-0000-000000000000
TransactionName: ACME Vending
TransactionstartTime: 11/10/2010 2:44:10 PM
TransactionDuration: 00:20:00
ParentTransactionGuid:
TransactionPercentComplete:
Transactions DataTable Contents, Record :1
TransactionGuid: 5d877ea2-cec2-4172-962a-b0c763c505a9
TransactionName: Deliver to (Lat,Lon): 0 , 0
TransactionDuration: 01:01:01
ParentTransactionGuid: 00000000-0000-0000-0000-000000000000
TransactionPercentComplete: 25
_______________________________________________________________________
This is what the repository code looks like:
using System;
using System.Data;
using System.Collections.Generic;
using GanttChart.DataAccess;
namespace GanttChart.Model
{
public class VendorRepository
private ServerTerminal serverTerminal;
private DataSet VendorRepo;
private DataTable theVendors;
private DataTable theTransactions;
private List<string> vendorList = new List<string>();
private static readonly VendorRepository instance;
public static VendorRepository Instance
get { return instance; }
}
static VendorRepository()
instance = new VendorRepository();
private VendorRepository()
InitializeRepos();
serverTerminal = new ServerTerminal();
serverTerminal.StartListen(2535);
public void InitializeRepos()
VendorRepo = new DataSet();
theVendors = VendorRepo.Tables.Add("Vendors");
theVendors.Columns.Add("VendorGuid");
theVendors.Columns.Add("VendorID");
theVendors.Columns.Add("VendorName");
theVendors.Columns.Add("VendorstartTime", typeof(DateTime));
//set the primary key to the VendorID Column
DataColumn[] keys = new DataColumn[1];
keys[0] = theVendors.Columns["VendorID"];
theVendors.PrimaryKey = keys;
theTransactions = VendorRepo.Tables.Add("Transactions");
theTransactions.Columns.Add("TransactionGuid");
theTransactions.Columns.Add("VendorID");
theTransactions.Columns.Add("TransactionName");
theTransactions.Columns.Add("TransactionstartTime", typeof(DateTime));
theTransactions.Columns.Add("TransactionDuration", typeof(TimeSpan));
theTransactions.Columns.Add("ParentTransactionGuid");
theTransactions.Columns.Add("TransactionPercentComplete");
theTransactions.Columns.Add("AllProperties", typeof(Byte[]));
DataColumn[] TransactionsKey = new DataColumn[1];
TransactionsKey[0] = theTransactions.Columns["TransactionGuid"];
theTransactions.PrimaryKey = TransactionsKey;
System.Data.DataRelation relOrdDet;
System.Data.DataColumn colMaster;
System.Data.DataColumn colDetail;
colMaster = VendorRepo.Tables["Vendors"].Columns["VendorID"];
colDetail = VendorRepo.Tables["Transactions"].Columns["VendorID"];
relOrdDet = new System.Data.DataRelation("RelOrdDet", colMaster, colDetail);
VendorRepo.Relations.Add(relOrdDet);
public Guid UpdateVendor(VendorData Vendor)
Guid id;
DataRow row = theVendors.Rows.Find(Vendor.vehId);
if (row == null)
// need to insert row
id = new Guid();
theVendors.Rows.Add(new Object[] { id, Vendor.vehId, Vendor.name, Vendor.startTime });
else
// need to update row
string idstring = row["VendorGuid"].ToString();
id = new Guid(idstring);
return id;
public void UpdateTransaction(TransactionData transaction)
DataRow row = theTransactions.Rows.Find(transaction.parentGuid);
Guid id = new Guid(transaction.parentGuid);
theTransactions.Rows.Add(new Object[] { id, transaction.VendorID, transaction.vendorName, DateTime.Now, TimeSpan.FromMinutes(20), null, null });
// Add transaction as a child of the vendor summary transaction
theTransactions.Rows.Add(new Object[] { Guid.NewGuid(), transaction.VendorID, transaction.name, DateTime.Now, transaction.duration, new Guid(transaction.parentGuid), transaction.transactionPercentageComplete });
_____________________________________________________________________
and here is what the form load event looks like:
private void BindingGanttView_Load(object sender, EventArgs e)
transactionRepo = this.SetupData();
this.ultraCalendarInfo1.DataBindingsForTransactions.BindingContextControl = this; this.ultraCalendarInfo1.DataBindingsForProjects.BindingContextControl = this; this.ultraCalendarInfo1.DataBindingsForProjects.SetDataBinding(transactionRepo.GetVendorRepository(), "Vendors"); this.ultraCalendarInfo1.DataBindingsForTransactions.SetDataBinding(transactionRepo.GetVendorRepository(), "Transactions");
this.ultraCalendarInfo1.DataBindingsForProjects.IdMember = "VendorGuid";
this.ultraCalendarInfo1.DataBindingsForProjects.KeyMember = "VendorID";
this.ultraCalendarInfo1.DataBindingsForProjects.NameMember = "VendorName";
this.ultraCalendarInfo1.DataBindingsForProjects.StartDateMember = "VendorstartTime";
// Set the DataBinding members for Transactions
this.ultraCalendarInfo1.DataBindingsForTransactions.NameMember = "TransactionName"; this.ultraCalendarInfo1.DataBindingsForTransactions.DurationMember = "TransactionDuration"; this.ultraCalendarInfo1.DataBindingsForTransactions.StartDateTimeMember = "TransactionstartTime"; this.ultraCalendarInfo1.DataBindingsForTransactions.IdMember = "TransactionGuid"; this.ultraCalendarInfo1.DataBindingsForTransactions.ProjectKeyMember = "VendorID";
this.ultraCalendarInfo1.DataBindingsForTransactions.ParentTransactionIdMember = "ParentTransactionGuid";
this.ultraCalendarInfo1.DataBindingsForTransactions.PercentCompleteMember = "TransactionPercentComplete";
this.ultraCalendarInfo1. DataBindingsForTransactions.AllPropertiesMember = "AllProperties";
this.ultraGanttView1.CalendarInfo = this.ultraCalendarInfo1;
this.ultraGanttView1.Project = this.ultraGanttView1.CalendarInfo.Projects[0];
Can anyone confirm that the databindings are setup correctly? If so, is there anything I can do debugging wise to gain more insight about why the control does not display the data? Something like the WPF trick of using a converter to examine a breakpoint?
Thanks!
Michele
You don't need to add tasks/projects, the data binding layer will handle that. My point is that you are giving your tasks a reference to a project by virtue of binding to the ProjectKeyMember, but you are assigning Projects[0] to the control's Project property, which means that none of the tasks obtained from the data source will be displayed since you haven't told the control to display that project.
Has this thread been closed?
Hmm. I'm confused as to why a project needs to be added to ultraCalendarInfo when I used the data bindings to bind it to my Model's data set. To illustrate, I assume that you meant I needed to do something like this example from Infragistics documentation:
private void CreateTasks() { // Create a new Project other than the Unassigned Project
Project quarterlyProject = this.ultraCalendarInfo1.Projects.Add("QuartlerlyProject", DateTime.Today);
quarterlyProject.Key = "projkey1"; // Create a Summary or Parent Task Task
requirementsTask = this.ultraCalendarInfo1.Tasks.Add(DateTime.Today, TimeSpan.FromDays(5), "Requirements", "projkey1"); // Create a child task Task
budgetTask = requirementsTask.Tasks.Add(DateTime.Today, TimeSpan.FromDays(2), "Budget Analysis"); Task teamTask =
requirementsTask.Tasks.Add(DateTime.Today.AddDays(3), TimeSpan.FromDays(3), Infragistics.Win.TimeSpanFormat.Days, "Team Allocation"); // Create a Summary or Parent Task Task
implemetationTask = this.ultraCalendarInfo1.Tasks.Add(DateTime.Today.AddDays(5), TimeSpan.FromDays(1), "Implementation", "projkey1"); // Create a child task Task
frontendTask = implemetationTask.Tasks.Add(DateTime.Today.AddDays(5), TimeSpan.FromDays(2), Infragistics.Win.TimeSpanFormat.Hours, "GUI Design");
But I wanted to follow the data source binding example code that came with the WinGanttChart sample project, like this:
// Set the BindingContextControl property to reference this form
this.ultraCalendarInfo1.DataBindingsForTasks.BindingContextControl = this;
this.ultraCalendarInfo1.DataBindingsForProjects.BindingContextControl = this;
// Set the DataSource and DataMember for Project and Tasks using the SetDataBinding method
this.ultraCalendarInfo1.DataBindingsForProjects.SetDataBinding(taskRepo.GetVendorRepository(), "Vendors");
this.ultraCalendarInfo1.DataBindingsForTasks.SetDataBinding(taskRepo.GetVendorRepository(), "Transactions"); // Set the DataBinding members for Projects
this.ultraCalendarInfo1.DataBindingsForProjects.StartDateMember = "TransactionStartTime";
this.ultraCalendarInfo1.DataBindingsForTasks.NameMember = "TransactionName";
this.ultraCalendarInfo1.DataBindingsForTasks.DurationMember = "TransactionDuration";
this.ultraCalendarInfo1.DataBindingsForTasks.StartDateTimeMember = "TransactionStartTime"; this.ultraCalendarInfo1.DataBindingsForTasks.IdMember ="TransactionGuid";
this.ultraCalendarInfo1.DataBindingsForTasks.ProjectKeyMember = "VendorID";
this.ultraCalendarInfo1.DataBindingsForTasks.ParentTaskIdMember = "ParentTransactionGuid";
this.ultraCalendarInfo1.DataBindingsForTasks.PercentCompleteMember = "TaskPercentComplete"; // All other properties this.ultraCalendarInfo1.DataBindingsForTasks.AllPropertiesMember = "AllProperties"; // Since we are showing a task that belongs to an explicitly defined // project (i.e., not the UnassignedProject), assign that project to // the control's Project property so the control knows to display that project.
this.ultraGanttView1.CalendarInfo = this.ultraCalendarInfo1; //Project
missionProject = this.ultraCalendarInfo1.Projects.Add("MAM", DateTime.Now);
In the example above, it seems like the code shows how to bind your data set to the Infragistics project. My question is, why do the data binding if you still have to manipulate rows and tasks directly through the ultraCalendarInfo object? I'm trying to model the MVVM design pattern, so I'd like the references to Infragistics to be cleanly contained in the view, without referencing the CalendarInfo object from the Model code.
Thanks for helping me understand!
ml_atkinson said:this.ultraGanttView1.Project = this.ultraGanttView1.CalendarInfo.Projects[0];