Hello,
I'm using a XamDatagrid with hierarchical data as datasource. And the structure of my datasource is like :
EmployeeConsolidatedCareer.yearsField[].consolidatedPeriodsField[].SalaryField;
I'm looking for a way to display only SalaryField. I can do that for a specifiec year :
<igWPF:XamDataGrid x:Name="datagrid"
DataSource="{Binding EmployeeConsolidatedCareer.yearsField[0].consolidatedPeriodsField}">
<igWPF:FieldLayout>
<igWPF:Field Name="SalaryField" Label="Salary" Width="Auto"/>
</igWPF:FieldLayout>
</igWPF:XamDataGrid>
Is there a way to get all SalaryField for All Year ?
Thanks for your help.
Hello pvdbpvdb,
Thank you for your post.
From the current binding that you have for your XamDataGrid.DataSource, you will not be able to see each SalaryField in your grid as you are only getting the first item in the yearsField collection.
What I would recommend is that instead of doing a complex binding for the data source in this case, you craft a new collection of your SalaryFields. For instance, you could use a nested for loop where the outer one loops through each entry in your yearsField and the inner one loops through each entry in the consolidatedPeriodsField and adds it to your new collection. This would effectively gather all of the SalaryFields into a single collection which you could then bind to the grid. The code for this would look something like:
for(int x=0; x < EmployeeConsolidatedCareer.yearsField.Count; x++){
for(int y=0; y < EmployeeConsolidatedCareer.yearsField[x].consolidatedPeriodsField.Count; y++){
newCollection.Add(EmployeeConsolidatedCareer.yearsField[x].consolidatedPeriodsField[y]; }}
datagrid.DataSource = newCollection;
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
That did the job.
Thank you Andrew for your assistance.