How to pass ajax.dataSrc to $.fn.dataTable.pipeline method?
How to pass ajax.dataSrc to $.fn.dataTable.pipeline method?
sathish_m
Posts: 9Questions: 4Answers: 0
Actually i want to pipeline concept for lazy loading. but i am not able to understand how to pass dataSrc to $.fn.dataTable.pipeline method. please can one help me?
This discussion has been closed.
Answers
See the dataTable initialisation in the example:
http://datatables.net/examples/server_side/pipeline.html
tangerine! thanks for your information. In that example only i am facing this issue. there is only data variable but there is no dataSrc. i am not able to understand how to configure dataSrc to the function $.fn.dataTable.pipeline. please tell me is there any another way.
You would need to modify the pipeline function where it uses
json.data
to use whatever the data property name is that you are using. That isn't configurable in the current code for that example.Allan
i replaced data property with dataSrc in $.fn.dataTable.pipeline method but i am getting following js error.
Uncaught TypeError: Cannot read property 'splice' of undefined.
at line
json.data.splice( requestLength, json.data.length );
in method $.fn.dataTable.pipeline.
Why would you do that? Is your data contained in a property called
dataSrc
? I don't see that change in your line of code above which still usesjson.data
.What does your JSON data look like?
Allan
allen! Thanks for your response. ok! leave everything. i am using below code and it is working fine. below code is for get json data from apache solr and data displayed in datatable. but it is fetching all data at a time. but now we need to apply the pipeline concept for this. could you explain me how to apply pipeline concept for below code.
$('#example').dataTable( {
"ajax" : { "url": "../solr/collection1/select?q=<query>", "dataSrc" : "response.docs" },
"columns": [
{ "data" : "field1" },
{ "data" : "field2" },
{ "data" : "field3" },
{ "data" : "field4" },
{ "data" : "field5" },
{ "data" : "field6" },
{ "data" : "field7" },
{ "data" : "field8" },
],
"jQueryUI" : true
} );
Change
json.data
in the pipeline function tojson.response.docs
.Allan
Hi Allan thanks for your suggestion i changed
json.data
tojson.response.docs
. i am getting following errorUncaught TypeError: Cannot read property 'length' of undefined
in line jquery.dataTables.min.js:36. please help to reslove this.
Based on the information provided so far, as far as I am aware that should work. Can you please give me a link to the page you are working on so I can debug it.
Allan
I am also facing this same issue when I am trying to implement the pipeline processing.
My Json didn't have object name so I remove the "data" from "json.data" now its giving error in jquery.datatable.min.js script
"TypeError: c is undefined
...isplay=parseInt(d,10);c=sa(a,b);e=0;for(d=c.length;e<d;e++)J(a,c[e]);a.aiDisplay..."
@sagarzope - Can you link to the page you are working on so I can debug it please?
Allan
Code for Ajax Pipeline
$(document).ready(function() {
Code for the datatable initialization'''
oTable =$('#example').dataTable( {
"processing": true,
"serverSide": true,
"autoWidth": false,
"ajax": $.fn.dataTable.pipeline( {
url: '/monitoring/dispatcherServlet/registrationController/getregistration?prof_ID='+obj[i].mp_ID,
pages: 5 // number of pages to cache
} ),
"columns": [
{
data: "duns",
render: function ( data, type, row ) {
if ( type === 'display' ) {
return '<input type="checkbox" id="'+data+'" onclick="getDuns('+data+');">';
}
//alert(data);
return data;
}
},
{ "data": "duns" },
{ "data": "organizationname" },
{ "data": "businesstype" },
{ "data": "organizationaddress" },
{ "data": "countrycode" }
],
my JSON is in following format
[{"status":"false","a":"b"}, {"status":"false","a":"b"}]
@allan : I cannot attached the page so I have given the part I am using for the datatable