Hey all,
I have a RadGrid on a Wpf page, it is goign to be loading data from a Astoria service. Right away, we need to bind it programatically - the declarative syntax won't work since I need to do some set up.
Ideally, I would grab a data subset and do the binding directly, but there is at least one problem... Astoria (int he release bits) doesn't support Count() so I cannot bind the grid directly. In other words, I cannot...
var corePages = contextCore.CmsPageSet.OrderBy(p => p.Title); |
pageListGridView.ItemsSource = corePages; |
Instead I have to...
var corePages = contextCore.CmsPageSet.OrderBy(p => p.Title); |
pageListGridView.ItemsSource = corePages.ToList(); |
Which is seriously suboptimal because it means grabbing all the records over the wire to project them into the list so that the grid is happy with them. Ugly, ugly, ugly.
It gets even worse because since this is not the astoria CTP2, I can't do projections on the server, either which means I pull down all the columns for each record, even though I only need three for the grid. I need Id, Title and Sortweight. Of those, I need Id to be hidden, so that I can access it as a key when a user clicks on a row (I need to pull up a window for the edit) but the user is not bothered with it in the grid proper.
So here are my questions....
- Has anyone managed a direct bind between a RadGridView and an astoria data service - am I barking up the wrong tree?
- How do you give the RadGridView a list of columns to use from a programtically bound data source? I knwo how to declare the columns, but I am unsure how to tie them to the (future) properties of the anonymous type I will be binding after the projection. UniqueName didn't seem to be enough. The documentation is very weak in this reguard.
- By any chance, does someone know the proper syntax for a lambda style .Select LINQ statement to pull multiple columns out?
Thanks!