Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
605
Getting the Records in the Inner most Group
posted

Hi,

     Iam using Infragistics XamDatagrid which is having say 8 columns and 100 records for example. I have grouped the grid with 2 Columns in the groupBy area which resulted in 7 rows(visible directly) and internally having remaining records. Now if i expand the first row, i get another group which is having 10 records in this example. Presently iam getting these records using XamDataGrid.RecordManager.Groups[currGroupId].ChildRecords  which iam casting as below 

new List<DataRecord>(AlertsGrid.RecordManager.Groups[currGroupId].ChildRecords.Cast<DataRecord>() where currGroupId is the Current GroupIndex which iam programatically setting in RecordActivated event. If i group with a single column then the above code works fine for me but if i group with multiple columns i get 

"Unable to cast object of type 'Infragistics.Windows.DataPresenter.GroupByRecord' to type 'Infragistics.Windows.DataPresenter.DataRecord'.

Now my question is how can i get hold of the set of DataRecords which are in the inner most Group of respective Outer Groups....this is urgent please help

thanks in advance

Ram

  • 69686
    Verified Answer
    posted

    Hello Ram,

    As the Exception implies, you are trying to case a GroupByRecord to a DataRecord, which is not possible.

    This code works for one field, because the DataRecords are direct children of the GroupByRecord. However, when you have multiple groupings, you would have a GroupByRecord inside a GroupByRecord etc.

    What you need to do is to check the RecordType property of the records when you get them from the first group. If they are still GroupByRecords, you need to get the ChildRecords once more, until you get to the DataRecords.