Lazily load data in jquery DataTable as per the request - jquery-ui

I am using jquery DataTables to populate tables. We can get huge size of data and render it on html and put pagination/search etc using DataTable. I haven't used it earlier but I assume that it will die sometimes (after a limit). And anyways, bringing whole data in one go might not help in future.
Is there any way to make ajax calls when user reaches the last page of DataTable and fetch remaining data?
I hope, I am clear. Any alternative to perform this job will be helpful.
Thanks,

Jquery DataTables has the ability to use server side paging. You can find detailed information here: Server Side Paging Documentation

Related

Transferring Result Data via HTTP Header? - Asp.Net MVC

I am trying to upload file without refreshing the page.
I got 1 form, 1 submit, 1 file input and 1 iframe in order to prevent refreshing.
Form sending data via iframe, so my form have target attribute.
After my c# function's work, I want to return result data, such as message, issuccess etc.
I don't know how to return result data without using http header.
Maybe it's also not possible with http header. I don't know. I am here to learn how to do.
Transferring result data via http header makes sense? Is it preferable way?
Does it occurs vulnerability?
Any other suggestions?
Thanks in advance.
Typically it's hard to get a file over the wire without a form post.
What I've done often is use an invisible iframe for a form post and then have the iframe call a function in the parent page upon load. This assumes you can't just use jquery or a recent version of dojo to take care of this for you.
http://viralpatel.net/blogs/ajax-style-file-uploading-using-hidden-iframe/
If you can use jquery it's much nicer. Edit: this is under the mit license
http://blueimp.github.com/jQuery-File-Upload/
Why not take advantage of the HTML5 File API. These links should point you in the right direction.
http://www.html5rocks.com/en/tutorials/file/dndfiles/
http://timothypoon.com/blog/2011/05/10/ajax-uploading-with-html5s-file-api/

What's the Best Way to Implement Paging with a List using jQuery Mobile and MVC?

I am building a media library from a tutorial to get up to speed on MVC 4. I did the whole thing and now I'm re-building it using jQuery Mobile. The only piece I've yet to find simple is paging which should be easy. Can someone steer me in the direction of a nice tutorial on the subject?
We do have similar kind of Use case.
Store the Data in Session object in the form of Dictionary in this form.
On click of Next or previous button in Pagination control, fetch data from Controller, bind data to appropriate control in the UI and show data.
Make sure to show only limited data in UI. Restrict the number[max 10 per page]
Format Dictionary

ASP.NET (MVC) - Drill down with hash

I'm currently working on a drilldown filter in MVC but I don't really know how to make this the fastest and most flexible as possible.
click here
Now my question is, how do you think they are doing this?
I've really no idea how to make this kind of drilldown but it seems they use some kind of hash they save for quick querying.
Maybe (pseudo)code anyone?
If you're willing to give up a little browser compatibility (it won't work on ancient and some console only browsers but then again neither will anything else), jQuery DataTables is a great way to make drilldowns.
Here is the main site, and Here is a good example of using a dropdown select to filter.
Basically all you have to do is throw all the data into a large <table> and use javascript on the client side to filter. The big benefit is there is no latency when you make a selection, unlike the site you linked.
I think it is not a good idea to put all data on the client side.
It is more reasonable to trust the data filtering to the database server (of couse it depends on your data size).
To speed up receiving the filtered data you can save it in your cache server with hash or select query as tag. Query to cache is faster than to database.
The answer after carefull looking at how they do it:
They send a normal http POST to the server with a querystring of all
choices.
The server sends back a http GET which returns an URL with the
hash.
The server caches the hash with the query so the next time the query is called it is faster.
Thanks everyone for your "usefull" responses.

MVC jqgrid Page Navigation When Data is Sorted

I am running a code with ASP .NET MVC jqgrid that populates the grid with data from the database.
The code is taken from :
http://jetmathew.wordpress.com/2011/03/02/asp-net-mvc-2-with-entity-framework-json-jquery-and-jqgrid/
The problem is that when I go to second page and sort the data with any column. It sorts the whole data but takes me to 1st page.
I want to remain on second page with whole sorted data. Is this a bug? And is there anyway around to get things go my way?
The sane thing is happening on all examples on this link as well.
http://www.trirand.com/blog/jqgrid/jqgrid.html
It's not a bug. Think about it, what meaning does the pagenumber have when the sortcolumn changes? IMHO none since you are looking at a different dataset...
What are you trying to achieve here?
edit
Craig Stuntz added Jquery BBQ integration to Jqgrid. This enables url history to jqgrid.
Using this you can take the current page from the querystring.
http://craigstuntz.github.com/jqGrid/
I still stand by my original answer though :)
/Daddy

Progressive enhancement - what to do when JavaScript is off?

I understand what progressive enhancement is, I'm just fuzzy on some of the details in actually pulling it off. Of course, that could be because I'm looking at it in the wrong way. Let me try to explain my difficulty with a hypothetical:
ASP.NET MVC site. I have a view that has tabbed navigation. Each tab is for a movie category/genre which displays 5-10 links to movies in that category. The movie data is obtained through Netflix's Odata.
My initial thought is to use Ajax to pull and parse the JSON from the proper OData GET requests when each tab is clicked. How would I provide a non-JavaScript version of that? Is it even possible?
For simpler requests where JSON isn't necessary - like, say, having a user log into the system - I see how I could simply set a cookie and dynamically change the page based on it to reflect the change. But what if I need to return and parse JSON? How do I provide an alternative?
The deal with progressive enhancement is that your server side must be fully capable of generating every last bit of HTML that appears in all of your pages. This is obvious, since otherwise (if JS is turned off) there will be no part of your application capable of doing said rendering.
Since the server side must know how to render everything, it doesn't make much sense to generate things (DOM elements/HTML) on the client side from JSON responses the server gives you. Why repeat yourself?
This brings us to the logical conclusion that when doing dynamic updates on the client, you need to get ready-made HTML from the server (since the rendering logic is over there) and insert it into the DOM as appropriate. You are then free to work on the newly inserted elements with jQuery and enhance them all you want.
So -- forget about parsing JSON on the client, otherwise you 're locking yourself out of progressive enhancement. If you want to call a third party, have the server be your intermediary: call the server with all the necessary information for it to call the third party and get ready-made HTML back.
If you do this, then the server can of course provide non-JS versions of everything on your site with no problem. Total non-reliance on JS achieved.
There is no JSON without JS, by definition (JavaScript Object Notation). Without JS you won't make AJAX calls. Your pages will render as is, just like oldschool sites.
If you need to do this progressively, you will have to call the odata service server-side, and provide .net objects to the site in viewdata, or your viewmodel, and have your views/partials render it.
In ASP.Net MVC actions, the httpcontext available via the controller will have a property on this path: this.HttpContext.Request.IsAjaxRequest() and can be used to test whether you want to return a view or just json data, or whatever type of ActionResult you want. This can be an excellent timesaver for building progressive enhancement style sites.

Resources