The problem with the Google Maps API in the swap table

Using Google Chart Tools with code like this:

<div id='table_div'></div>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['table']});
google.setOnLoadCallback(drawTable);
function drawTable() {
  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Country');
  data.addColumn('number', 'A');
  data.addColumn('number', 'B');
  data.addColumn('number', 'Total');
  data.addRows([
      ['United States',     19, 115, 134],
      ['United Kingdom',     3,  23,  26],
      ['Germany',            2,  19,  21],
      ['Ireland',            0,   3,   3],
      ['Belgium',            2,   3,   5],
      ['Russian Federation', 0,   2,   2],
        ...
  ]);

  var table = new google.visualization.Table(document.getElementById('table_div'));
  table.draw(data, {showRowNumber: true, page: 'enable', pageSize: '10', sortColumn: 3, sortAscending: false});
}
</script>

This causes a strange paging problem. With 38 counties, each page shows:

  • # 1 - 10 countries (1 to 10)
  • # 2 - 28 countries (11 to 38)
  • # 3 - 18 countries. One way or another, although the second page has already listed the remaining countries, there is a third page that lists countries from 21 to 38, again
  • # 4 - 8 countries (31 to 38) that have already been indicated

JSFIDDLE http://jsfiddle.net/HT3St/

I tested the code also on Code Playground and the same question occurred. Is this some kind of known mistake that I don’t know about?

+1
source share
2

, , , , :

 var options = {
   alternatingRowStyle:[true],
   pageSize:[20],
   page:['enable']
    };

  options['pageSize'] = 20; <- This line fix the problem.

:)

+1
{showRowNumber: true, 
 page: 'enable', 
 pageSize: '10', 
 sortColumn: 3, 
 sortAscending: false
}

pageSize . 10. ,

pageSize: 10,
+2

All Articles