I have a view which displays data ->parsed json which comes after sendig request to back end.
The request parameters contains page ad page size which defualts to page=1 and page size to 20.
Now i require a pagination in view that helps to see the records by allowing users to select 10 records per page,20 records and 100.
The data parsed json is already available in view .
PLz, help me what should i do cause when user for the first time opens the page only 20 record should be displayed and when he select 100 record the page it should show 100 records.
I am thinking that you have an HTML drop down that says 20 results (and 50 and 100 and so on) and then when he changes this, it should show on the page right?
For this you can set an event handler for the dropdown's onChange() event which makes an AJAX call to your server (and passes the number of results required along with the offset if any as parameters) - and returns your results which you can display.
This is how I'd do it.
Related
I have one problem, i fetch data from one URL and set it to Table but if data is almost 10 to 15 values. then i get data in table easily means table data populated in less time.
But if Data is almost 500 to 600 values then one have to wait till all data come as i have used ProgressView so user have to wait till all response doesn't come.
is there is any way to resolve this, to set some data earlier and then after all data that i have got afterwards.
Any help will be appreciated
you should use pagination support in your tableView and in your backend as well, please see this example:
https://easyiostechno.wordpress.com/2014/11/14/pagination-of-table-views/
Basically it's a bad practice to fetch large data at once and keep user waiting. You should ideally fetch data only when it's necessary. For your case I would suggest you to use paging mechanism.
Below is just rough idea about paging which you can use:
When you load your data from webservice, send two parameters named
PAGE_COUNT and PREVIOUS_PAGE_COUNT.
For first time send PAGE_COUNT = nuber_of_values_you_want_to_fetch_initially and PREVIOUS_PAGE_COUNT
= 0
When user scrolls down showing loader at the bottom of table and again hit webservice but with PREVIOUS_PAGE_COUNT = nuber_of_values_you_want_to_fetch_initially + PAGE_COUNT
This approach will need some modification from back-end also like checking for initial page count and then fetching next records from
database.
I hope this will help you.
I am using the OnNeedData feature with an array feeding a number of qrLabels in a detail band configuration - (Delphi 2010 and QuickRep5) - On a multi-page report, I need to detect every next page (2, 3, 4 etc) and modify the first line in the detail band.
Everything works fine except that the internal page number variable (QuickReport.QRprinter.pagenumber) does not increment before the first line is printed (or shown).
As an exemple, if I print a spam removed of labels with the caption equal to the page number,
the first line of page 2 will show Page 1 and the rest of the lines on that page will show correctly Page 2 same thing happens for all other pages.
Can someone help me to find a way to properly identify the beginning of a new page, I have tried OnEndPage, OnStartPage, BeforePrint, etc. without success - the counter always increment after the first line of the detail band has been printed...
Thank you
Make sure that the Quickrep1 has a PageheaderBand
Then examine the QuickRep1.QRPrinter.PageNumber in the OnBeforePrint event handler of that PageHeaderBand.
i am using Listgrid of smartgwt api. i have set filter editor on the list grid using setShowFilterEditor(). On UI, i can filter out the text from the particular columns using filter editor which is shown on top of listgrid. till this, everything works fine. but problem starts after this. my ListGridRecords are of type ScreenInstanceGridRecord.
I cleared out the filter criteria before getting the ListGridRecord from the ListGrid using method clearCriteria(), so that i can save all the records to database ie. unfiltered records. when i try to get records from the listgrid using getRecordList(), 1000 Dummy records are added on the fly on first iteration, all my populated records are ignored . and i need here is records of ScreenInstanceGridRecord type. but on second iteration, i am getting my populated records which is of ScreenInstanceGridRecord type. why this problem is occurring. i should be getting ScreenInstanceGridRecord on the first iteration itself when i try to get records from the ListGrid using getRecordList(). i am getting no idea about this weird thing. any help from your side is most welcome.. plss
When you say you're getting 1000 Dummy records instead of your loaded records, in fact, your Records are not loaded yet at all. In this case, the ResultSet created by the ListGrid (see docs for ListGrid.fetchData()) is returning a provisional length (defaults to 1000) and returning the loading marker in lieu of Records (see ResultSet.rowIsLoaded()).
Use the DataArrived event to take action once data has been loaded. See ResultSet.lengthIsKnown() for how you can, in general, tell that data is not yet loaded.
In the process of implementing this feature and wanted to get some suggestions.
When a user lands on this one page on my site, I get the user's connections from linkedin (via an API call). Now I need to display these connections on my page 10 connections at a time for some further processing. After loading the first 10 initially I want to give the user an option to load 10 more connections (by hitting a button), and then 10 more, etc.
I was thinking of implementing this in such a way that when user arrives on page, I make the API call, get all connections at one time, store them all into a JSON object and then display the first 10. If the user asks for the next 10, then I read the next 10 from the JSON object.
Is this the best way I can achieve this paging ability? Is using a JSON object a good way of going about it? Note, idea here is to prevent making muletiple API calls since Linkedin has a daily limit. Thanks.
I like this method, especially for something like Autocomplete where there will be a server-side request every time the user makes a keystroke. I noticed that it was putting a lot of strain on my server (because the autocomplete gets used on the app almost 24/7). So I'll use an example from my code for you to adapt. It's for entering in playlists.
I have an action in my PlaylistEntriesController called playlist which respond to JS:
def playlist
#all_playlist_entries = PlaylistEntry.scoped # just a dump of all the playlist entries for autocomplete
end
Then in playlist.js.erb:
<% cache 'playlist_entries', :expires_in => '1.day' do %>
var titles = <%=raw #all_playlist_entries.map(&:title).uniq.to_json %>
var artists = <%=raw #all_playlist_entries.map(&:artist).uniq.to_json %>
var albums = <%=raw #all_playlist_entries.map(&:album).uniq.to_json %>
var autocomplete_options = { delay: 100, autoFocus: true, minLength: 3 };
<% end %>
And then I simply pass those javascript variables as the "source" for the autocomplete. It's FAST (tested with 100,000 entries, database response time was something like 4 seconds and the actual autocomplete is still almost immediate), and even better, it only requires one call to the database each day, since it's cached, as opposed to THOUSANDS. The downside is, of course, that new entries won't be available until the next day, but in my case that is not a big issue.
So this is not exactly how you would implement it, but it will work. You can make one call to the LinkedIn API and store the results in a javascript array as json objects (using to_json, which you can override in the model if you need to). Then have a link that says Show 10 more, which will do some jQuery magic to show the next ten (I can't do it off the top of my head but it will be a matter of finding out how many are showing, either with a javascript variable or storing the number as a data-attribute or id on each DIV, and then getting the next 10 in the array).
I Created A VIEW IN MY ASP.NET MVC APPLICATION.
View class retrieves a data of 6100 rows
that class is used in one of my view which fills grid with data it can also be sorted.
it will load nicely for first time then sorting also works fine but when i click on last page link it takes time and finally gives following error
The timeout period elapsed prior to completion of the operation or the server is not responding
anyone can help me please i am not getting WATS the problem
Sounds like the request time is reaching the max allowed (default in ASP.NET = 30 secs). I don't think its as the back button as much as the request is randomly taking 29 secs, 31 secs, etc.
You may want to try a pagination approach to displaying your data instead of loading 6,100 rows at once - this will reduce the load times.
Check out this link for a pagination example.
Another idea would to use page caching. But I would recommend pagination.