Server-side paging with google visualization API - how do I get paging controls to show?

118 views
Skip to first unread message

da...@distribion.com

unread,
Oct 30, 2015, 1:17:28 PM10/30/15
to Google Visualization API

If I initialize a table like this:

    google.load("visualization", "1.1", {packages:["table"]});
    google.setOnLoadCallback(drawTable);
    table.draw(data, {showRowNumber: true, width: '100%', height: '100%',
               page: 'enable', pageSize: '25', allowHtml: true});

How can I make it work with server-side paging? I mean, if I set pageSize to 25, and then I only give it 25 records, it's only going to show that I have one page, and I'm not going to get any active paging controls. How can I tell it that I have 1500 records, say, when I'm only giving it 25 records at a time?


Daniel LaLiberte

unread,
Nov 4, 2015, 8:44:52 AM11/4/15
to Google Visualization API
@daleg, check out the pagingButtons option:  https://developers.google.com/chart/interactive/docs/gallery/table  You'll have to compute the number of pages you'll need if you want the page number controls, or you can just display the next and prev page buttons.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/02df0f98-5066-4b2c-b322-53800fd09af0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

Arthur Young

unread,
Nov 5, 2015, 5:36:29 PM11/5/15
to Google Visualization API
Daniel,
Either I don't understand how it works, or else the pagingButtons option isn't working properly.  
In this jsFiddle, http://jsfiddle.net/artelliot/vt4uvght/, if I run it without the pagingButtons: 'auto' option it appears to work, but if I uncomment the pagingButtons: 'auto' line, I only get two disabled arrow buttons.

Is it me?

Thanks,
Arthur

Arthur Young

unread,
Nov 5, 2015, 5:41:26 PM11/5/15
to Google Visualization API
Quick note, if I pass a number value, it works properly.  I'm thinking that I am not understanding the purpose of the pagingButton option.  If it is set to 'auto', I expect it to compute the number of pages and buttons for me.  Is that correct?

Daniel LaLiberte

unread,
Nov 5, 2015, 8:43:04 PM11/5/15
to Google Visualization API
If you only give the Table chart 25 records, it can't know about the rest of your 1500 records, so that's why you would have to compute the number of pages you want and use that number with the pagingButtons option.  If you give it all the 1500 records, and specify that the pageSize should be 25, then it will display 25 records per page and compute the number of pages for you.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.

da...@distribion.com

unread,
Nov 6, 2015, 3:31:23 PM11/6/15
to Google Visualization API
The problem I'm having is that the buttons are disabled if your data has the same number of rows as you've given for the page size. I guess I could just fake it, and put my own buttons down there.

But surely I must be missing something. I looked at TableQueryWrapper, but I haven't been able to get it to work. The best I've gotten out of that so far is "Uncaught Error: Missing query for request id: undefined". I think there's insufficient documentation on that for me to be able to implement it correctly.

I got this Chart example working:


using my data and using Table instead of Chart, so maybe I can cobble something together from that.


On Wednesday, November 4, 2015 at 7:44:52 AM UTC-6, Daniel LaLiberte wrote:
@daleg, check out the pagingButtons option:  https://developers.google.com/chart/interactive/docs/gallery/table  You'll have to compute the number of pages you'll need if you want the page number controls, or you can just display the next and prev page buttons.


--
dlali...@Google.com   5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA
Reply all
Reply to author
Forward
0 new messages