10 Answers, 1 is accepted
RadDomainDataSource supports paging with the help of the PageSize property. You can easily throw a RadDataPager in and it will start paging it automatically.
It does not have a LoadSize property.
To learn more about RadDomainDataSource please read the following blog posts:
· Introducing RadDomainDataSource for Silverlight
· Loading data with RadDomainDataSource for Silverlight
· An MVVM Approach to Telerik Domain Services for Silverlight
· Creating CRUD application with RadDomainDataSource for Silverlight
· Why we have built RadDomainDataSource for Silverlight?
You can also learn more about the WCF RIA Services technology here.
I hope this helps.
Ross
the Telerik team
I recently modified my Ria DomainDataSource for a RadDomainDataSource because my RadGridView was not sorting correctly.
Since I modified my DomainDataSource I am experiencing an issue with the RadDomainDataSource and RadDataPager, as soon as I am setting a value for the PageSize property my RadDataGridView will show only the number of row as my PageSize and my e.TotalEntityCount returns -1.
Is this a known issue?
Can you assist?
Several other customers complained that their e.TotalEntityCount became -1 when they upgraded to the official version of WCF RIA Services SP1. Is this your case as well?
Also, is there an Error returned by the server?
The thing is that RadDataPager needs to know this number (TotalEntityCount) in order to calculate the page count. Otherwise it cannot do the math.
It would be perfect if you can send us a sample project that actually reproduces this, since no one has managed to do so yet.
Ross
the Telerik team
I have some news thanks to Sébastien, who sent a project that reproduces this weird behavior.
I have found a solution for those of you who get a TotalEntityCount of -1 for one reason or another. As you know, when the TotalEntityCount coming back to the client is -1, the paging calculations cannot be done correctly because the total amount of items needs to be known.
After some searching, I finally found this blog post. Many thanks to his author.
I tried to test it on Sébastien's sample project and... it worked. Here is what I added and the TotalEntityCount miraculously started coming back to the client, thus enabling correct paging:
public
IQueryable<BatisseHistoriquePoids> ObtenirBatisseInvHistoPoids(
out
int
totalCount)
{
List<BatisseHistoriquePoids> retour =
new
List<BatisseHistoriquePoids>();
BatisseHistoriquePoids a1 =
new
BatisseHistoriquePoids();
a1.DateSortie = DateTime.Now;
a1.CedReelleRowid_ =
new
byte
[] { 1, 2, 3, 3, 44, 4, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 2 };
retour.Add(a1);
BatisseHistoriquePoids a2 =
new
BatisseHistoriquePoids();
a2.DateSortie = DateTime.Now.AddDays(1);
a2.CedReelleRowid_ =
new
byte
[] { 5, 2, 33, 3, 44, 4, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 2 };
retour.Add(a2);
BatisseHistoriquePoids a3 =
new
BatisseHistoriquePoids();
a3.DateSortie = DateTime.Now.AddDays(2);
a3.CedReelleRowid_ =
new
byte
[] { 8, 2, 33, 3, 44, 4, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 2 };
retour.Add(a3);
totalCount = 3;
return
retour.AsQueryable().OrderBy(tt => tt.DateSortie);
Here is what I found in the DomainOperationEntry class:
internal
object
Invoke(DomainService domainService,
object
[] parameters,
out
int
totalCount)
{
if
(
this
.HasOutCountParameter)
{
object
[] array =
new
object
[parameters.Length + 1];
parameters.CopyTo(array, 0);
array[parameters.Length] = 0;
object
obj2 =
this
.Invoke(domainService, array);
totalCount = (
int
) array[parameters.Length];
return
obj2;
}
totalCount = -1;
return
this
.Invoke(domainService, parameters);
}
So, everything is clear.
In case your server-side method is "normal", i.e. you get the Customers from Northwind, then you should not need to add this out parameter. But if you are getting a TotalEntityCount of -1 on the client, you can use this approach. Let me know if you find anything else regarding this topic. It turned out to be very interesting.
Has anyone noticed whether MS changed the TotalEntityCount behavior between the SP1 Beta and the official SP1 of WCF RIA Services? Does anyone know?
Regards,
Ross
the Telerik team
Hello Ross and thanks for your help.
It did take care of our issue but this is clearly a workaround that need to be fixed in the next release.
We found out that the RadDomainDataSource is not working as the RiaDomainDataSource does. When we changed for the RadDomainDataSource the chain of event changed and we now try to load some data too early and the parameter is not set as it used to be with the RiaDomainDataSource.
I'll try to figure this one out but will contact you if needed.
Thanks and regards
Can you try to remove AutoLoad=true from XAML and do it in the PageLoaded event handler? This should trigger the first ever trip to the server after all parameters have been initialized on the client.
As for the other issue -- it is not exactly a workaround. We simply need the TotalItemCount to be known so we can do the math. If you notice, the MS DataPager will not show the total number of pages when it is on page one. It does not know them either. It simply plays it clever and hide the visual element that is supposed to show the total number of pages.
By the way, please take a look at this forum post for a more proper implementation of the count logic than the out int parameter. Basically, you can override Count method of the DomainService.
I hope this helps.
Ross
the Telerik team
Thank you for posting this workaround. We now have a TotalEntityCount and the RadDataPager is working.
However, now we have a new issue. When the user adds a filter to the grid (RadGridview bound to QueryableDomainServiceCollectionView on VM), the TotalEntityCount is always equal to the total amount of entities, not the number of filtered entities. This obviously causes the RadDataPager to show an incorrect number of pages. If the user tries to navigate to page 3 when there are really only two pages of results, an error occurs. Same error occurs if the applied filter results in zero records.
Any ideas on how to get an accurate TotalEntityCount?
Thank you,
Brian
Indeed the problem comes from the fact that TotalItemCount is not correct.
I'll try to clarify a little bit. When you place a filter via RadGridView filter UI, this triggers two actions "filter" on the client side and due to that also "filter (load)" (with AutoLoad = true) on the server side (which in fact is the query method on the server), so this query method should respect the applied filter and should return correct TotalItemCount.
I hope this makes sense.
Nedyalko Nikolov
the Telerik team
Brian