This is a migrated thread and some comments may be shown as answers.

Syncing RadGridView and RadDataform with QueryableCollectionView

5 Answers 53 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Johannes
Top achievements
Rank 1
Johannes asked on 22 Jan 2015, 02:23 PM
I want to syncronize my RadGridView with my RadDataForm. Defining a CollectionViewSource in the XAML of the view bound to an ObservableCollection in the ViewModel does not work 100% because this will fail when we set a filter on the RadGridView. So after taking a look at your demos and manuals it seems that I have to use your QueryableCollectionView class to achieve correct syncronization.

In your demo you use QueryableCollectionView inside your ViewModel but the class needs Telerik.Windows.Data and WindowsBase.dll. Both of this DLLs are imho attached to "view stuff" and should not be in the ViewModel. In my case my ViewModel project is a portable class library which makes it impossible to import any of those view related libraries.

So here's the question? Can I use QueryableCollectionView in XAML like CollectionViewSource? If not how else can I get 100% working syncronization?

5 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 24 Jan 2015, 12:47 PM
Hello,

You can try a slightly different approach and achieve similar results. Basically, RadGridView uses DataitemCollection, which is Telerik's alternative to the .net itemsCollection, which uses a QueryableCollectionView to add IQueryableSupport. So that, if you bind RadDataForm's ItemsSource directly to RadGridVIew's Items property, RadDataForm will use RadGridView's QCV internally, instead of creating a new one and you will have synchronization. I am attaching a simple demo project.

Regards,
Ivan Ivanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Johannes
Top achievements
Rank 1
answered on 29 Jan 2015, 10:45 AM
Thank you for your hint. It works. However this is getting difficult if RadGridView and RadDataForm are not directly in the same UserControl/XAML. If both controls are located in different child UserControls I can not use DataBinding with ElementName because RadDataForm does not know/find RadGridView.

So for the moment I'm using a wrapper class containing the ViewModel class and the IQueryableCollectionView and this class is located in the View project. There I can add "view related stuff" to it.
0
Ivan Ivanov
Telerik team
answered on 29 Jan 2015, 11:45 AM
Hello,

Well, these controls being in different views complicates the things. Does the solution with the wrapper class is appropriate for? if not, we can think of some attached behavior that propagates one and the same QCV instance as an ItemsSource for both of them?

Regards,
Ivan Ivanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Johannes
Top achievements
Rank 1
answered on 02 Feb 2015, 11:37 AM
In my opinion it's absolutely okay to have another small layer between View and ViewModel where I put things in that can not reside in the (portable class library) ViewModel project like IQueryableCollectionView. So yes, I'm fine with this solution.

Thanks again for support.
0
Ivan Ivanov
Telerik team
answered on 02 Feb 2015, 11:59 AM
Hi,

I am glad to hear that the issue is solved and I am closing the ticket for now. Please, feel free to open it again if you need any additional assistance.

Regards,
Ivan Ivanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
DataForm
Asked by
Johannes
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Johannes
Top achievements
Rank 1
Share this question
or