I have one doubt in the Virtual Collection, Say we have total 25 records and the Page size is 10 so the total page's are 3. VirtualCollection works on the basis of start index, basically in the first page start Index is zero, 2nd page start index is 10 but when I go to 3rd page start Index is 15, i think this is wrong why because in my 3rd page I want to show only 5 records i.e from 20 to 25. Which is not happening in Virtual Collection. Am I assuming anything wrong?
Thank you
Hi ptilwani,
I am not sure what do you mean when you say "Virtual Collection works on the basis of start index".
If by StartIndex you mean DataItemRequested args StartIndex property then you've probably mixed the paging and caching. StartIndex and DataItemRequested are not directly related to the paging capabilities. Basically when the XamGrid needs to display a certain page it tries to access the items from that page then VC searches its cache for requested by the grid Items. If they are not in the cache VC requests the items by firing the DataItemRquested for those items that are not in the cache. And finally when they are loaded into the cache they are displayed.
I've attached a sample solution you could check out.
Regards
Hi,
I meant StartIndex as DataItemRequested args StartIndex property. Thank you for response. The problem was with VirtualCollection declaration. I specified the LoadSize as 10 while declaring a Virtual collection. Now I removed the Load size and just specified the Anticipated Count. It works fine.
Thank you.
And one more thing I observed is if i have 20 pages in the Grid then I dont think all the 20pages will be cached in to the Virtual Collection. I mean to day i will load pages from 1 to 20 pages all the data needs to be added in to the Virtual Collection. And when i come back from 20 to 1 page no it will not all the pages data by virtual collection. It will load the data from virtual collection only from 20 to 15 after that when i click on 14th page it will go to server and will get the data. Does it works like this only or am I missing something?
Hello ptilwani,
Unfortunately XamGrid with Virtual Collection does not support Filtering out of the box. For more details how you could make it work check out this thread.
I couldn't managed to understand what was the second issue you had observed. Basically the VC request every page when the user tries to navigate to it. If the page is had been already requested and can be found in its cache it does not request it again. There is certain conditions when the whole cache is cleared for example when you perform grouping. After this every page is requested again.
If this does not answer your question please give explain in in more details and if possible in more clear manner. Or you could provide simplified solution illustrating the issue you have noticed.
I tried the same sample which you provided earlier (VCSample). From that sample I changed the anticipated Count to 225 instead of 25 while created Virtual Collection object(_collection = new VirtualCollection<TestData>(225))
When i run the application i got 23 pages. I changed the page number from 1 to 2,3,4,5,6,7,8 and so on till 23 and then I came back in a reverse way 23,22,21,20,19,18 and on click page no 17 th it raised the _collection_ItemDataRequested event to get the data for the 17th Page.
This what I wanted to know why It raised the ItemDataRequested Event here. To reproduce the same can you please run the sample and change the page numbers and check.
I investigated the case you are asking about. This basically happens because the internal cache of VirtualCollection have some sort of max size - it is something around 20 times the value of LoadSize property.