Hi all, I'm a newbie here. I using XamDataGrid version 9.1 . I would like to asking about the '+' sign shown in expandable records grid.
Is there any event handler if we click the expandable records on the '+' sign on the grid? I need to know if the '+' sign was clicked. I even found out if I click the '+' sign, the grid it self had got no focus.
FYI :
when I initialize my grid, I using FieldLayouts inside the FieldLayouts. It will make the records have children (sub record).
Thanks.
Vera
Hi Alex,
On clicking of the button, when record1 is expanded to display the child records, I need to apply style - say change background color of the child records.
I changed the code in the loop as below. But the presenter is always null. This code does not work as expected. But, when I expand record1 and then click the button, I notice the style being applied. Is there a way, I could get the datapresenter when initially the record is not expanded and the expansion happens only when I click the button.
foreach
(var child in dr.ViewableChildRecords){
sb.Append(child.ViewableChildRecords.Count.ToString() +
Environment .NewLine);
foreach (var c1 in child.ViewableChildRecords)
{
DataRecordPresenter presenter = DataRecordPresenter.FromRecord(c1 as DataRecord) as DataRecordPresenter;
if (presenter != null) // Is always null -- why ??
// Get DataRecordCellArea of that VLL recordDataRecordCellArea drca = Infragistics.Windows.Utilities.GetDescendantFromType (presenter, typeof(DataRecordCellArea), false) as DataRecordCellArea;
if (drca == null) return;
drca.Background = new SolidColorBrush(Colors.Green);
}
sb.Append(c1.ToString() +
Environment.NewLine);
wow alex. I using your example. And it works. Thanks you very much for your help. I'm really2 happy.. :)
thanks,
Vera,
This is correct, the first time you get the ViewableChildRecords, it returns only one records, ExpandableFieldRecord which holds the rest of the DataRecords. That is why you have to get the ViewableChildRecords one again.
Please take a look at the attached sample about how to do this.
Regards,Alex.
hmm... It's only return 1 record. can we take all the reords child?
Thanks again. :)
When you expand the record, you can get its ViewableChildRecords.
For example:
foreach (var child in e.Record.ViewableChildRecords) { foreach (var c1 in child .ViewableChildRecords) { // child records } }
you can also access them through the fieldlayout, for example
xamDataGrid1.FieldLayouts[1].Records.
Note, that by default settings, the second layout (FieldLayouts[1]) would be generated after at least one record of that layout has been initialized, because of the Virtualization techniques.
Alex.