Hi!
I have a feature request, where I have to activate grouping only if the group-operation will result in more than one group. If there will be only one group, I have to display a “flat” list. Is there an easy way how I can achieve such a behaviour?
To provide a little bit more background information.
Best regards,HiCo
Hello Hico,
Thank you for your post.
I have been looking into it. I am not sure that I understand your requirements correctly. If you want to check the number of groups in XamDataGrid, you can handle it`s Loaded event. In the event handler of Loaded you can get the count of current groups by using Count property and access it by RecordManager.Groups collection of XamDataGrid. In order to be able to clear the groups, if their count is equal to one, you can use Clean method of SortedFields collection. I created a short sample application based on your scenario to show you how you can implement the functionality that you are looking for. If the attached sample application does not meet your goals, would you please modify it with the functionality, that you are using. This way I would be able to further investigate your requirements for you and provide you with more detailed information on this matter. Please let me know if I am missing something about your scenario.
Please let me know if you need any further assistance.
Hi Zhivko,thank you for the sample. Unfortunately it did not solve my problem. I changed your sample to reflect my current scenario a little bit better. As you will see in the sample project, the bound data-source will be populated AFTER the Loaded-Event of the DataGrid and furthermore will be changed over time.
My business model “Person” should be grouped by “gender”, but if all entries have the same gender, there should be no grouping. If I add another person with gender set to a different value, a new record should be added and the grouping should be activated.
I would need something like a DataSource-Changed event. I tried SourceUpdated and OnRecordAdded, but the events did not fire - maybe because the “change” is code-triggered.
During the preparation of the attached sample-project, I found another possible solution. I used the RecordsInViewChanged event. If this event fires, I perform an update of the groups. This will only solve my problem partial, since this event will not fire if I change the gender of an existing record. I solved that by applying the workaround from http://es.infragistics.com/community/forums/t/7569.aspx. That brought me one step closer to the final solution, but one thing is still missing. I am now able to activate the grouping if necessary, but deactivating will not work. In addition to that, the OnValueChanged event will not fire if the record is not in view.
I’m a little bit lost. :)
Best regards HiCo
I am just checking if there is anything else I can do for you.