Hello,
I have an unbound hierarchical radgridview that has a parent template and two child templates. The master templates work fine, I can insert, type or paste data. But in the child template, I cannot add any data or rows. It remains blank. Can you tell me what I am doing wrong?
My code are below.
Thank you in advance.
private void TestForm_Load(object sender, EventArgs e)
{
// Setup the Master Template
RadGrid.MasterTemplate.Columns.Add (new GridViewTextBoxColumn("Name"));
RadGrid.MasterTemplate.Columns.Add (new GridViewTextBoxColumn("Description"));
RadGrid.MasterTemplate.Columns.Add (new GridViewDateTimeColumn("Date"));
RadGrid.MasterTemplate.Columns.Add (new GridViewDecimalColumn ("Value"));
RadGrid.MasterTemplate.Columns.Add (new GridViewTextBoxColumn("Status"));
RadGrid.MasterTemplate.Columns.Add (new GridViewTextBoxColumn("NameCode"));
RadGrid.MasterTemplate.Columns.Add (new GridViewTextBoxColumn("Event"));
RadGrid.AllowAddNewRow = true;
RadGrid.AutoGenerateHierarchy = true;
RadGrid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
//Setup Child Template
GridViewTemplate Childtemplate = new GridViewTemplate();
RadGrid.MasterTemplate.Templates.Add (Childtemplate );
Childtemplate.AllowAddNewRow = true;
Childtemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
Childtemplate.Columns.Add (new GridViewTextBoxColumn ("Name"));
Childtemplate.Columns.Add (new GridViewTextBoxColumn ("Description"));
//Relation between Parent & child
GridViewRelation relation = new GridViewRelation(RadGrid.MasterTemplate);
relation.ParentTemplate = RadGrid.MasterTemplate;
relation.ChildTemplate = Childtemplate;
relation.ParentColumnNames.Add("Name");
relation.ParentColumnNames.Add("Description");
relation.ParentColumnNames.Add("PtDate");
relation.ParentColumnNames.Add("Value");
relation.ParentColumnNames.Add("Status");
relation.ParentColumnNames.Add("NameCode");
relation.ParentColumnNames.Add("Event");
relation.ChildColumnNames.Add ("Name");
relation.ChildColumnNames.Add ("Description");
RadGrid.Relations.Add(relation);
//load data
LoadUnboundData();
}
{
using (RadGrid.DeferRefresh())
{
TestDataSet Processes = new TestDataSet();
using ( RadGrid.DeferRefresh())
{
GridViewTemplate firstLevelTemplate = RadGrid.MasterTemplate.Templates[0];
for (int i = 0; i < Processes.AllProcesses.Count; i++)
{
TestDataSet.AllProcessesRow ProcessRow = Processes.AllProcesses[i];
RadGrid.MasterTemplate.Rows.Add(
ProcessRow.Name,
ProcessRow .Description,
ProcessRow.Date,
ProcessRow .Value,
ProcessRow .Status,
ProcessRow .NameCode,
ProcessRow .Event
);
for (int j = 0; j < Processes.ProcessTasks.Count; j++)
{
TestDataSet.ProcessTasksRow TasksRow = Processes.ProcessTasks[j];
firstLevelTemplate.Rows.Add(
TasksRow.Name,
TasksRow.Description
);
}
}
}
}
}