I am not defining FieldLayouts before hand and dynamically binding the Collection of data to the grid at runtime. I have names of certain properties of this data on whom I want to disable the GroupBy feature.For e.g., if I have data on cities I want to prevent grouping by pincode as pincodes are unique and grouping by that doesn't make sense.Is it possible to do this programmatically in XamDataGrid?
Hello,
Thank you for your post.
I have been looking into your requirement and I am not sure that I understand it correctly. What I can suggest in order to be able to achieve the functionality that you are looking for is to handle Loaded event of XamDataGrid. In the event handler you can access the Field you want and set it`s AllowGroupBy property to false, so you will disable the ability to group the grid by this field. I created short sample application based on your scenario to show you how you can implement this approach. Please let me know if I am missing something about your scenario and if this is still an issue for you send me, an isolated sample project , where this is reproduced or modify my sample application with the functionality that you are using, so I can investigate it further for you.
Please let me know if you need any further assistance on the matter.
I have been investigating further your requirement. It seems that in your scenario more appropriate event would be FieldLayoutInitilized event of XamDataGrid instead of lLaded event. You can take a look at the following link from our online documentation:
http://help.infragistics.com/Help/Doc/WPF/2015.1/CLR4.0/html/InfragisticsWPF4.DataPresenter.v15.1~Infragistics.Windows.DataPresenter.DataPresenterBase~FieldLayoutInitialized_EV.html
where you can find more details about FieldLayoutInitilized event. Also I am not sure how exactly you are defining your FieldLayout. If you define it in XAML part , you can set AllowGroupBy property of Field class directly.
Looking forward to hearing from you.
Handling the FieldLayoutInitilized event worked for me. I did it as follows:
In xaml-
<utils:XamDataGrid x:Name="CitiesGrid" Theme="IGTheme" FontSize="13.0" DataSource="{Binding Path=Cities}" FieldLayoutInitialized="CitiesGrid_OnFieldLayoutInitialized" />
In Code-
private void CitiesGrid_OnFieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e){ e.FieldLayout.Fields["pincode"].Settings.AllowGroupBy = false;}
Thanks. :)
Thank you for your feedback.
I am glad that you have managed to resolve your issue.