I want to implement server side paging in my Silverlight application. To get an idea of the steps that I would require I went through this custom paging in asp.net
article where they described how to design a SQL query to return the results according to the Page Requested and the Total no of records per page. I am however totally confused as to how am I going to call it from my Silverlight application. Like how am I going to specify it in the c# code.
The default paging using the DataPager is pretty simple.
PagedCollectionView pagingCollection = new PagedCollectionView(e.Result); //e.Result contains `List` returned by the method that calls the stored procedure GetProducts
pagerProductGrids.Source = pagingCollection;
gridProductGrid.ItemsSource = pagingCollection;
But I'm clueless about the procedure of doing it on my own. Like what properties I will be needing to get and set the Page Size, the total no of records etc i.e how am I going to configure my DataGrid and DataPager to pass StartingRowIndex and Maximum RowcOunt
Please help!
I came across this article a few years ago and this worked like a charme for me. I've added this to my framework and have been reusing this method ever since. The article is well explained and I believe this is exactly what you are looking for.
Paging Data from the Server with Silverlight
Related
In a method that takes the parameters int pageNum and int pageSize I am trying to return data from dynamics based on that specific page and size.
I am using a QueryExpression and I set the exp.PageInfo page number and page size to achieve this which works fine until page 51 with a page size of 100 which produces the error "Paging cookie is required when trying to retrieve a set of records on any high pages"
This brings me to near duplicate question territory (such as Dynamics CRM - How to get the second page of a fetchXml query beyond the 5000 elements? ) but the claims "you do not need the paging cookie" are just not correct at all it seems, there is nothing I can do for results beyond 5k that do not produce that error.
I am now paging over -the entire result set- (which allows me to get the PagingCookie from the previous results to pass to the next page request) and then returning the data I want from that set, but that is super slow. I have made it faster by dynamically altering the query in the paging loop so it only returns columns if the current data is in the requested page range which has shaved about 30secs off the query, but still very slow for such a large data set.
So, is there A) some thing that will enable me to get these high results without a paging cookie? Is this a QueryExpression limitation for example? or B) a faster way of handling this problem than iterating over all results until the page I want?
Thanks.
Unfortunately there's no way to "fast forward" to high pages in your query result.
You'll have to use the paging cookie just the way you are doing right now.
If you knew the last and next record from a previous query you could try creating a high-page-cookie to start with.
As #Aron suggest in his answer, the only improvement might be gained from sorting and/or filtering/partitioning the data (by createdon, etc.).
Filtering the data set to return fewer pages might be something to investigate. Or, if the desired page is closer to the end of the data set, reverse the sort order.
I am trying to get a paged list of call records from Twilio
var records = Twilio.Rest.Api.V2010.Account.CallResource.Read(pageSize: 10).ToList();
But nowhere is there anywhere to specify what the page number to retrieve is? How would I do this?
Sales Engineer at Twilio here.
There isn't a way to go to a specific page. You can navigate through the pages using the previous_page_uri and next_page_uri fields. I think the philosophy is that pages are a very implicit/arbitrary way of navigating your data. It's better to be explicit about what you're actually looking for, e.g., "Records from this date to this date" by using query parameters like this:
Category=calls&StartDate=2017-10-13&EndDate=2017-10-13"
I have an index page where a table is generated with rows of information from the DB.
I have successfully integrated Tom Dykstra's method of adding a search box using this tutorial: http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application
How would I implement behavior that shows names that already exist as they are being typed in the search box, or automatically update the rows in the table as something is typed into the search box?
I am using MVC 5 with EF6.
Thank you!
I would use the jQuery UI Autocomplete widget with a remote source for the data.
https://jqueryui.com/autocomplete/#remote
For the remote source either write a new action on your controller that returns JSON, or a WebAPI action to do the same, and in there do a query against your database to find matching results for the users query
The best way to do this would be to use AngularJs. We can't give you a full example of this, I can only give you an approach. Angular is very powerful and as well it is client side which speeds up you application very much. See the example shown in the docs of angular.
You can use the filtering on everything (tables, divs, list etc.)
https://docs.angularjs.org/api/ng/filter/filter
Here is an example of how to implement AngularJS in Asp.Net MVC.
http://www.codeproject.com/Articles/806029/Getting-started-with-AngularJS-and-ASP-NET-MVC-Par
Here is also an JSFiddle example on how it can look like:
http://jsfiddle.net/mikeeconroy/QL28C/1/
<tr ng-repeat="product in products | filter:search | orderBy:'name'">
<td>{{product.name}}</td>
<td>{{product.category}}</td>
</tr>
This code snippet would do the filtering for you
I am utilizing Devexpress Gridview and I am having a caching problem.
I have developed a page like here: http://mvc.devexpress.com/GridView/SimpleCustomBinding
It is working as it is supposed to be. However, if I update a column value in the database (Mssql), Gridview does not change the value.
Searched the web and found EnableRowsCache must be false but I could not implemented it since I think this property is available for different kind (or version) of Gridview and We have been using MVC extensions.
Does anybody know how to disable cache and make it show the "fresh" data?
------ UPDATE ------
After a lot of digging and searching, it is clear now that the caching is not due to devexpress, but it is the result of linq to sql. It is a property of linq that it caches the results of view and does not show the updated value.
This issue was a major headheache to us and now I have come up with a conclusion with my colleague.
PROBLEM
First of all, suppose that you have a view in your db, name: ViewBook
ViewBook
Id | Title | Author
And you write the following query:
(from VB in Connection.ViewBook
select VB).ToList();
As a result you will get a list of rows.
Then, if you update a row in your db, this query will not show the fresh data, still returns the old data.
SOLUTION
In order to solve this, first define an object:
public class ViewBookObject : ViewBook
{
//this object will have all the properties of ViewBook.
}
then in the query:
(from VB in Connection.ViewBook
select new ViewBookObject {
Id = VB.Id,
Title = VB.Title,
Author = VB.Author
}).ToList();
This query will always show the fresh data.
CONCLUSION
I have written this solution to here for people who have similar problem to this situation.
I hope this helps everyone.
I'm trying to determine the best approach for performing paging.
I have two options of grabbing data using SubSonic:
1) itemDatumCollection.LoadAndCloseReader(sp.GetReader());
or
2) itemsDataSet = sp.GetDataSet();
With both I am accessing the same stored procedure. Is there a simple way of paging with LoadAndCloasReader()?
I could load all the data through GetDataSet on the client - say 4000 rows, but seems unnecessary, and this amount of data exceeds my WCF binding parameters (which I think are set pretty good) when I use LoadAndCloseReader() as it returns a complex object:
maxBufferSize="20000000" maxBufferPoolSize="524288" maxReceivedMessageSize="20000000"
So a couple of things I guess:
1) Is GetDataSet() faster at returning data - I don't need the complex collection object (it's just nice when coding)?
2) How can I perform paging using my TSQL sproc?
Thanks.
I went with an approach used more in MVVM, rather than MVC. I loaded all the data up front, then allowed the user to page through it using a jQuery paging control, there-by minimizing return calls to the database. The initial response takes a bit longer (but is limited to 100 records), but provides the user with lightening-fast paging.
I used the Simple Pager jQuery plugin.