Hello,
I am new to Infragistics and try to make my first steps.
The goal is to have two datagrids, that can use copy&paste and drag&drop unidirectional. (grid A -> grid B). It is a .net 4.5 app with MVVM. I am using xamDataGrid.
Grid A contains all employees - that works fine. Grid B contains a list of jobs (=construction sites of the company) and a week, one column per weekday and the task assignments for each job inside the cell of each job and weekday.
Each job can have mulitple employees per day assigned. I use a listview inside the cell to show the existing assignments. This works as expected.
<igDP:TemplateField Label="Montag" Name="Montag" IsReadOnly="True"> <igDP:TemplateField.DisplayTemplate> <DataTemplate> <ListView ItemsSource="{Binding .}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" BorderThickness="0"> <ListView.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding DisplayText}" TextWrapping="Wrap" ToolTip="{Binding ANMERKUNG}"/> </DataTemplate> </ListView.ItemTemplate> </ListView> </DataTemplate> </igDP:TemplateField.DisplayTemplate></igDP:TemplateField>
I want to implement following functions:
1. The user selects one or multiple employees in grid A and copies them to the clipboard (in their own class) -> this works
2. The user selects one or multiple cells in grid B and pastes the content of the clipboard
a) I am not able to create an array of SelectedItems that contain only the cells of datagrid B, it always shows the full row.
<igDP:XamDataGrid SelectedDataItemsScope="RecordsOrCells" SelectedDataItems="{Binding SelectedArbeitseinteilungen}" DataSource="{Binding Baustellen}" Grid.Row="1" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"ClipboardCopying="CopyArbeitseinteilungen" ClipboardPasting="PasteArbeitseinteilungen" GroupByAreaLocation="None" >
3) The user select 1 or multiple assigned employees inside one cell = one weekday and deletes them (e.g DEL key)
4) One or multiple cells of grid B are selected = means multiple listviews and the user deletes them or pastes a different content
The main problem is (in my understanding) about the relation of the xamDataGrid and its cells that are listviews in this case:
*) Which event is sent to which control (xamDataGrid or ListView)
*) Binding the commands to the right object inside the ViewModel (ItemsSource of Grid B vs. ItemsSource of each single cell)
I hope that I was able to explain the question and look forward to get this thing done.
Thanks
Niko
Hello Nikolaus,
Thank you for your feedback.
I am really glad, I could help out. If you do not have any further questions regarding this thread, please verify thread as answered, so it helps other users as well.
Regarding the other questions that you have I can suggest to create a separate thread for each of them. This way the communication would be easier and there would be no confusion about the issues. Also other community that have similar issues would be able to benefit from the threads too.
Thank you for using Infragistics controls!
thanks for the follow up on this question.
The main issue is to understand, which control is receiving which event. The tool snoop helped here a lot.
This works so far:
1. Paste into a cell that has no content
2. Paste into a cell that has already content inside a listview
3. Delete the existing content
What will be done next:
Bind the events directly to the viewmodel and remove the code behind stuff.
I understand that I have two different scenarions:
a) there is no content -> the xamDatagrid is receiving the events
b) There is content inside the cell = a listview -> the listview is receiving the event
I have to build the functionality step by step. At this point in time I don't have a specific need for support.
I will come back when the next question hits me ;-)
I am just checking if you require any further assistance on the matter.
I have been looking into your requirements and I am not sure that I understand correctly your scenario.
You can use ClipboardPasting event of XamDataGrid. From ClipboardPastingEventArgs you can get the receiver DataItem and cell for example:
var recieverDataItem = (e.Source as XamDataGrid).ActiveDataItem as JobInfo;
var recieverCell = (e.Source as XamDataGrid).ActiveCell;
also you can get the collection which contains the clipboard items by using Values property of ClipboardPastingEventArgs. You can take a look at the following link from our online documentation for more details about this event:
http://help.infragistics.com/doc/WPF/2015.2/CLR4.0/?page=InfragisticsWPF4.DataPresenter.v15.2~Infragistics.Windows.DataPresenter.DataPresenterBase~ClipboardPasting_EV.html
What I can suggest you in order to determine which event is fired when delete items is to use the ‘Snoop’ tool. It is a tool, that you can use to see the visual tree and check, which is the element, that you want to style or template. By using this tool and perform some actions you can observe events which fires as a result of your actions. You can find more details about this tool and how you can use it from the following forum thread:
http://es.infragistics.com/community/forums/t/97514.aspx
Please let me know if you require any further assistance on the matter.
Hello Zhivko,
I want to copy multiple items from DataGrid1 to DataGrid2.
This screenshot will give an idea: www.bauradar.at/vBaustellenEinteilung.png
The problems are:
Basically I have a list inside a cell of a datagrid and need to understand the relation of the datagrid the listview inside the cell. How can I bind a method or event to the listview (inside the cell)?