Is there a way to disable Group by drag and drop?. I want to handle Group by on right click of column (using runtime code) instead of allowing drag and drop.
Hello,
I am very glad that the approach I have suggested helped solving your issue. If you need any further assistance on the matter, please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Thanks for the reponse. That was helpful.
As we are not allowing drag and drop, with following code I've removed group by area prompt2 text.
Infragistics.Windows.DataPresenter.Resources.Customizer.SetCustomizedString("GroupByArea_Prompt2", "");
Thank you for your reply. I have been looking into the functionality that you are looking for and I can suggest leaving the GroupByAreaLocation to its default value and also canceling the Grouping event. This way you will see the GroupByArea and you will prevent the grouping by dragging and dropping fields. Here is how you can implement this approach:
Xaml:
<igDP:XamDataGrid BindToSampleData="True" Grouping="XamDataGrid_Grouping"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:LabelPresenter}"> <EventSetter Event="MouseRightButtonDown" Handler="Label_RightClicked"/> </Style> </igDP:XamDataGrid.Resources> </igDP:XamDataGrid>
C#:
private void XamDataGrid_Grouping(object sender, Infragistics.Windows.DataPresenter.Events.GroupingEventArgs e) { e.Cancel = true; }
I am very glad that the approach is working in your scenario. If you need any further assistance on the matter, please let me know.
Thanks for the response.
Is it possible to still show the group by panel (to know which columns are group by) and not allow drag and drop (will do group by on right click of column) ?
Thank you for your post. You can disable the Drag and drop of the fields to the GroupByArea, by setting the GroupByAreaLocation property of the XamDataGrid to None. After doing so you can create a style for the LabelPresenter and handle its MouseRightButtonDown event and there you can add a new FieldSortDescription with the field that corresponds to the LabelPresenter to the SortedFields collection of its FieldLayout. I have created a sample application for you that demonstrates how you can implement this functionality.
If you need any further assistance on the matter, please do not hesitate to ask.