Hi,
I have an ICollectionView ViewSource bound to my XamDataGrid.
How can I add a new item to the ViewSource and display it below the ActiveItem from my ViewModel.
Grouping/Filtering should be ignored for the new item, therefore, newRecord.RefreshSortPosition(); is no option.
Best
Oliver
Hello Jan-Oliver,
Thank you for your post.
I have been looking into your requirement and that I can suggest in order to be able to achieve the functionality that you are looking for is to use command with Command Parameter. You can get the SourceCollection and the current active record index and by using the Insert method of ObservableCollection you can add the new item at the position that you wish.
I created short sample application based on your scenario to show you how you can implement this approach and achieved your requirements. Please let me know if I am missing something about your scenario. Take look at the sample application and if it doesn’t cover your expectations feel free to modify it with the functionality that you are using, so I can investigate it further for you.
If you require any further assistance, please do not hesitate to ask.
Hi Zhivko,
the example only works as expected if you don't sort or group.
E.g. if you click on Hulk and then 2 times on add, it works as expexted.
If you sort by Firstname afterwards and press 2 times add again, the new items are not added directly below Hulk.
The same issue exists for grouping, filtering is not active in your example.
Jan-Oliver
Thank you for your feedback.
I have been investigating the functionality that you are looking for. In order to be able to be able to insert new item at specific position in XamDataGrid, when it has sorted fields, you can use ViewableRecords collection. In order to get the underlying data from this collection, you need to convert the Records into DataItems and synchronize your DataSource with the collection. By using ViewableRecords collection you are able to get the current position of each record when they are sorted. If you want to adding new record when there are filtering records in XamDataGrid, you can try to implement your custom logic with ExternalFiltering. You can take a look at the following link for more details about how can create external filtering in XamDataGrid:
http://help.infragistics.com/Help/Doc/WPF/2015.1/CLR4.0/html/xamDataGrid_External_Filtering.html
Also you can see sample, that demonstrate external filtering capability in XamDataGrid from our Samples Browser under the tag XamDataGrid -> Organization -> External Filtering.
I modified the last sample application to show you how you can implement the functionality that you are trying to achieve. It currently is not available in XamDataGrid and the sample application that I have attached is showing a custom approach that can be used as a guideline for implementing the functionality that you want.
Please let me know if you require any further assistance on the matter.
I am just checking if you require any further assistance on the matter.