Hi team ,
I need to get Group Name while grouping using dragging columns in group by area section with new version i.e InfragisticsWPF4.DataPresenter.v18.2
previously it was working fine when i was using v9.2.but after upgradation of infragistic version its not working . Could you plese help for this issue
But now i am unable to get group name after upgrading infragistic version i.e InfragisticsWPF4.DataPresenter.v18.2
Below i mentioned
private void DraggedGroupByCommandExecute(object parameter) //This Event is drag and drop groups { XamDataGrid dg = parameter as XamDataGrid; if (dg == null) return;
var data = dg.GroupByArea.GroupedFieldLabels; //picking favorite group name
}
Hello Sachin,
By design, InvokeCommandAction executes a specified ICommand on a specific target object when invoked. Via this ICommand the DraggedGroupByCommandExecute event can be triggered.
public class DropCommand : ICommand { public event EventHandler CanExecuteChanged; public bool CanExecute(object parameter) { return true; } public void Execute(object parameter) { DraggedGroupByCommandExecute(parameter); } private void DraggedGroupByCommandExecute(object parameter) { //...TO DO } }
This command can be called in the Grouped event handler. In this handler we can get reference to the GroupEventArgs ,where we have information about all grouped columns.
private void DataGrid_Grouped(object sender, Infragistics.Windows.DataPresenter.Events.GroupedEventArgs e) { MyCommand = new DropCommand(); MyCommand.Execute(e); }
When passed to the DraggedGroupByCommandExecute method we can obtain the collection with grouped columns via the Gropus property of the event argument and each column can be accessed by index. For example:
private void DraggedGroupByCommandExecute(object parameter) { Infragistics.Windows.DataPresenter.Events.GroupedEventArgs param = parameter as Infragistics.Windows.DataPresenter.Events.GroupedEventArgs; var data = param.Groups; int index = data.Length - 1; string LastGrouped = data[index].FieldName; MessageBox.Show(LastGrouped); }
Additional information regarding properties and functionalities you can use through GroupedEventArgs class can be found here.
Attached you will find a small sample illustrating my suggestion for your reference.
Please do not hesitate to contact me if you need any further assistance with this matter.
0083.XamDataGrid_GetGroupNameWhileDragging.zip
We are following MVVM Architecture . below you can see
i am triggering "Grouped" event and with this event I am binding "DraggedGroupByCommand" Icommand and with command parameter we are passing complete xamdatagrid
xaml :
<igDP:XamDataGrid Grid.Row="4" Name="ReportDataGrid" DataSource="{Binding Path=AvailableDocumentList}" IsGroupByAreaExpanded="True">
<i:Interaction.Triggers> <i:EventTrigger EventName="Grouped"> <i:InvokeCommandAction Command="{Binding DataContext.DraggedGroupByCommand,RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding ElementName=ReportDataGrid}"></i:InvokeCommandAction> </i:EventTrigger>
</igDP:XamDataGrid>
ViewModel :
private void DraggedGroupByCommandExecute(object parameter) //This Event is drag and drop groups{XamDataGrid dg = parameter as XamDataGrid;if (dg == null) return;
I hope now you get more clear picture about requirement .
Thank you for posting in our community.
From the description provided I assume that you want to get the name of the column you are currently grouping by while you dragging. My suggestion for achieving your requirement is handling “Grouping” event where the column name is accessible via the event argument. Depending on your scenario, the name of this column can be stored in a global variable, which will be accessible in any method within your application.
For example:
string nameOfGroupByColumn = null; private void DataGrid_Grouping(object sender, Infragistics.Windows.DataPresenter.Events.GroupingEventArgs e) { nameOfGroupByColumn = e.Groups[0].FieldName; MessageBox.Show(nameOfGroupByColumn); }
Attached you will find small sample illustrating my suggestion.
Please test it on your side and let me know if you need any further assistance.
1106.XamDataGrid_GetGroupNameWhileDragging.zip