New Posts New Posts RSS Feed: What is the best way to have paging in cocktail
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

What is the best way to have paging in cocktail

 Post Reply Post Reply
Author
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Topic: What is the best way to have paging in cocktail
    Posted: 15-May-2012 at 12:40pm
Hi,

I want to use the paging in some scenario and I am looking for the best way to do it with cocktail.

DevForce currently offer 2 possibilities (using an EntityQueryPager or an EntityQueryPagedCollectionView) but I don't see how it is possible to use them with the different pattern present in Cocktail.
To be able to use the EntityQueryPager I need to access it from the VM. Having methods from the SearchRepository where the result would be a Query is I think an anti pattern.
For the EntityQueryPagedCollectionView I need to provide a query for its constructor. So it's again I can't use it in the viewmodel. Another possiblity could be to instantiate the Collection in the SearchRepository and return it from there but again I don't like it much.

If I can't use thoses 2 classes I can still create methods which could take as parameters the page index and page size and do myself the skip/take. So far looks like the best solution but is it really ?


To resume, can anyone indicate to me the best way to work with paging in Cocktail ?


Anotther question, does Devforce provide a similar functionnality as the TotalEntityCount of the WCF RIA DomainClientResult  ?
I'd like to use the VirtualQueryableCollectionView of Telerik (the solution with the page index and page size looks like the best fit for it) and knowing the totalcount of the query dataset is needed to set the size of the collection. I would like to avoid the need of having a  "Count" query for each search method in my repositories.


Thanks

Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 15-May-2012 at 1:35pm

So far when doing paging I have added methods to my repositories that return an EntityQueryPager and then from the ViewModel I can move pages. That still hides the query details in the repository as it should be. The EntityQueryPager is an abstract object over the paging operation.

Unfortunatley, you need a count method. There isn't a total entity count in DevForce. When you do a search you call the count method on the repository and when the count returns you initiliaze the virtual collection of your grid and the grid will then start requesting the pages it needs with the actual data.
 
Most work goes into figuring out and dealing with the various events of whatever grid you use. Virtual grids are great from a UI perspective, but are a pain to implement, especailly if you want to filter, sort and group.
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 17-May-2012 at 4:46am
Hi marcel,

It seems it's not possible tu use the EntityqueryPager<T> with a projection.
The documentation says it works for Entity or Anonymous type. A test project did confirm it, both works but the projection isn't, the result is always empty (note : doing a MoveToLast set correctly the TotalItemCount property ...).
Any reason it doesn't work for the projection ?

I know it's possible to use an anonymous type and use the dynamicTypeConverter for the binding but how can I return an EntityQueryPager<T> from my repository when I don't know what is T ?







Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 17-May-2012 at 4:26pm
Hi Walid,

I'm not sure I understand your question. Anonymous and projection are 2 words that more or less mean the same thing. A projection query can result in an anonymous type, but you can also project into a custom type.

I've incorporated our current EntityQueryPager sample with the 2 concept above. Search for TestPagerWithCustomTypeProjection and TestPagerWithAnonType in the sample.

Let me know if that's not what you're looking for.


Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2012 at 1:47am
Hi Denis,

I found out the problem, I didn't use the QueryStrategy properly.

My code was something like:

query.With(QueryStrategy.DataSourceOnly);
return new EntityQueryPager(query, ...)

So the QueryStrategy wasn't applied ! Now it's all good, thank you.
Back to Top
siko View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Mar-2012
Posts: 27
Post Options Post Options   Quote siko Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2012 at 12:20am
Originally posted by mgood

So far when doing paging I have added methods to my repositories that return an EntityQueryPager and then from the ViewModel I can move pages. That still hides the query details in the repository as it should be. The EntityQueryPager is an abstract object over the paging operation.

<snip/>
 
Hi, I'm doing/trying the same, but not sure how to do it so that I still will be able to 'Busy-wait' when a paging operation is in progress. I should return the PageChangedOperation<T> on the LoadPagedQueryXAsync methods on the repository?
 
Thanks for any guidance


Edited by siko - 07-Jun-2012 at 12:21am
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2012 at 10:43am
No, you would return a "hot" EntityQueryPager from the repository and hang on to it in the ViewModel. Then call the asynchronous Move methods in response to user actions. The asynchronous Move methods will return you a PageChangedOperation<T>, which you'll use to handle busy state.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down