we have a datagrid setup as a treeview that is loaded on demand (too many records to do it any other way).
we have tried iterating threw all the children of a specific 'node' and seting there tag to a small string.
for some reason when we start to access the children of a large node... there are no children...but it's self.
which is very odd since there should be as many as we see below it.
-Matt
Matt,
When you call the ChildRecords collection of a record, it returns the ExpandableFieldRecordPresenter. It does not have any DataRecords in it. You have to access the ViewableChildRecord collection of the ExpandableFieldRecordPresenter. For example, here is how your code should look like to access the first set of child records of a DataRecord:
HighlightChildren(addedRecord.ChildRecords[0].ViewableChildRecords);
...
private void HighlightChildren(ViewableRecordCollection efrc)
{....}
Note that you can have more that one ChildRecords.
Here you are:
private void dgRight_Drop(object sender, DragEventArgs e) { XamDataGrid dragSource = dgLeft; XamDataGrid dragTarget = sender as XamDataGrid; //Get Instance of the dragger DataRecordPresenter and DataRecord DataRecordPresenter draggedPresenter = e.Data.GetData(typeof(DataRecordPresenter)) as DataRecordPresenter; DataRecord draggedRecord = draggedPresenter.Record as DataRecord; dragTarget.DataItems.Add(draggedRecord.DataItem); MarkAsAdded(draggedRecord); sortGrid(dragTarget); IsSaved = false; btnFormSave.IsEnabled = true; }
private void MarkAsAdded(object p) { DataRecord addedRecord = (DataRecord)p; if (addedRecord.ChildRecords.Count >= 1) { HighlightChildren(addedRecord.ChildRecords); } addedRecord.Update(); }
private void HighlightChildren(ExpandableFieldRecordCollection efrc) { foreach (Record r in efrc) { DataRecord dr = r as DataRecord; if (dr != null) { dr.Tag = "Bold"; DataRowView row = dr.DataItem as DataRowView; if (row != null) { if (row["IsFolder"].ToString() == "True") { dr.Description = "Italic"; if (dr.ChildRecords.Count >= 1) { HighlightChildren(dr.ChildRecords); } } } } } }
Thanks,
-Matt.
Hello Matt,
Could you paste us the code that you are using to iterate through the child records so that we can find the problem?