0

I have a table and data in the table i have stored to jquery variable, but i have applied pagination to the table, so only current values of table are getting stored to variable, and the next page entries of table are not, the code is as below, how to get all values in the table to be stored to a jquery variable? can anyone help..?

$("#button3").click(function(){

    arr = new Array();
    $("td").each(function () {
        t = $(this).text();
        arr.push(t);
    });

    var pdf = new jsPDF();
    pdf.setFontSize(3);
    pdf.text(35, 25,arr);
    pdf.save('message.pdf');
});
user1386654
  • 51
  • 3
  • 9

1 Answers1

0

You can use a temporary counter variable and push the code if limit is up to that.

$("#button3").click(function(){
    var limit = 10;
    var count = 0;
    arr = new Array();
    $("td").each(function () {
        t = $(this).text();
        if(count <= limit){
        arr.push(t);
        count ++;
       }
    });

    var pdf = new jsPDF();
    pdf.setFontSize(3);
    pdf.text(35, 25,arr);
    pdf.save('message.pdf');
});
Nabeel Arshad
  • 467
  • 2
  • 7
  • 22
  • this is not working, i ahve 5 entries on my page, its still showing only 5 entries even when i increased limit, i need to go to next 5 entries to dwnload its data to pdf, but i want to do it on same page – user1386654 Jul 05 '13 at 11:26
  • This is a little ambiguous. Are you using the pagination by any plugin or from the server side? – Nabeel Arshad Jul 05 '13 at 11:35
  • im using a js code for pagination, its stored in my directory with datatables.js and in my code m calling my table on it as shown on datatables.net – user1386654 Jul 05 '13 at 11:48