Load Data - newbie
Load Data - newbie
Hi,
I'm testing DataTable on mvc application (Razor Engine).
I've put this on my cshtml
$(document).ready(function () {
$('#ClientList').dataTable({
"bProcessing": true,
"bDeferRender": true,
"sAjaxSource": 'JRicercaClienti'
});
});
into the controller
public ActionResult JRicercaClienti()
{
var Clienti = new List();
var query = DB.tb_clifor.Where(m => m.k_clifor >= 0 && m.cognome != "" && m.nome != "").ToList();
return Json(new { aaData = query.Select(m => new string[] { m.cognome, m.nome, m.indirizzo}) }, JsonRequestBehavior.AllowGet);
}
Question: can DataTable load only 10/25 records at time and load them when user click button next/prev?
In this case, My application load all data at once...I don'tlike that.
Regards.
I'm testing DataTable on mvc application (Razor Engine).
I've put this on my cshtml
$(document).ready(function () {
$('#ClientList').dataTable({
"bProcessing": true,
"bDeferRender": true,
"sAjaxSource": 'JRicercaClienti'
});
});
into the controller
public ActionResult JRicercaClienti()
{
var Clienti = new List();
var query = DB.tb_clifor.Where(m => m.k_clifor >= 0 && m.cognome != "" && m.nome != "").ToList();
return Json(new { aaData = query.Select(m => new string[] { m.cognome, m.nome, m.indirizzo}) }, JsonRequestBehavior.AllowGet);
}
Question: can DataTable load only 10/25 records at time and load them when user click button next/prev?
In this case, My application load all data at once...I don'tlike that.
Regards.
This discussion has been closed.
Replies
Yes - use server-side processing :-).
Docs: http://datatables.net/usage/server-side
Example: http://datatables.net/release-datatables/examples/data_sources/server_side.html
Allan
I'm try it.
Now I've changed controller and cshtml.
But why when I click next, $(document).ready(function () don't reload?
What next? The paging control? It doesn't reload the Javascript function - no. Have a look in Firebug and you'll see it make an Ajax request for more data.
Allan
Regards