Getting new data using Pipeline

Getting new data using Pipeline

mokumaxmokumax Posts: 7Questions: 0Answers: 0
edited March 2011 in General
Hi,

I love this plugin but i'm having a hard time figuring out how to do what I want to do. Hoping you can help.

I'll be loading a "master" set of skeleton records. Basically, say, 5000. They'll come from my database. I'll only display up to 100 records per page. When i display those 100 records I'll be loading full details for them (not just the master thinned out data).

So... what I want to do is load the master data for paging and then as I page, load 'that' page's full details.

I found this link below but I"m not sure exactly how to go about it.

http://datatables.net/examples/server_side/pipeline.html

I'm using ajax calls to my c# WebMethod. My ajax call looks something like this:

[code]
var divToBeWorkedOn = '#AjaxPlaceHolder';
var webMethod = 'Web.asmx/GetInfoByDates'
var parameters = "{'sDate':'" + sDate + "','eDate':'" + eDate + "'}"

$.ajax({
type: "POST",
url: webMethod,
data: parameters,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$(divToBeWorkedOn).html(msg.d);
},
error: function(e){
$(divToBeWorkedOn).html("Unavailable");
}
});

[/code]

thanks for any help!
Craig

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Interesting one - I've not come across an approach like this before - but it sounds like a really good idea to me. So probably the easiest way I can think of to do this is to use fnDrawCallback to get the data. fnDrawCallback will fire whenever the page is drawn - which in this case would be with just your skeleton data. In place of the details (assuming that they would be part of the drawn table) you could put a 'loading...' indicator. Then fire off an XHR to get the specific details and place them into the table (just regular DOM methods would do for that).

    A couple of things worth noting about this approach - you won't be able to use the filtering on the details (since DataTables doesn't have the full data set - if you wanted that then server-side processing might be a suitable option). Also, without some clever caching, it would do the data loading thing on every draw - even for rows that it has already got.

    Another approach - which is probably a bit more difficult to implement would be to use the pipelining example you linked to, and have that in the background go and get the detailed data, and just gradually build up the full set (almost a deferred loading).

    Allan
This discussion has been closed.