Tabular pagination - How to change the rows per page with aldeed:tabular


#1

Hi, I’m trying to display some data using the aldeed:tabular package.

The data is displaying just fine and pagination works. However, I’d like to set the default number of rows per page to a different value than 10, which seems to be the package default. I’ve tried passing the table function and option object with what seems like the correct data from the table documentation, but it has no effect.

TabularTables.Visits = new Tabular.Table({
  name: 'Visits',
  collection: Visits,
  columns: [
    { data: 'date', title: 'Date' },
    { data: 'value', title: 'Value' },
  ],
  options: {
    ordering: false,
    pageLength: 50,
  },
});

Am I missing something in the syntax? Or should I be taking a different approach to adjusting the table?


#2

Try moving your pageLength property out of the options object, like:

TabularTables.Visits = new Tabular.Table({
  name: 'Visits',
  collection: Visits,
  columns: [
    { data: 'date', title: 'Date' },
    { data: 'value', title: 'Value' },
  ],
  pageLength: 50,
  ...
});

pageLength is a DataTables property, so setting it like this should make sure it gets used.


#3

D’oh! Well that’s simpler. Thanks for the help.