Search code examples
google-app-maker

AppMaker - Navigate to Last Page on Table


Scenario: I have a calculated SQL that returns 100 results. Added a table (from this calculated SQL) and limited the size of the page by 25 results. This will generate 4 pages. Pager form AppMaker works well (navigates between pages) but i need a button that navigates directly from page 1 to the page 4. is this possible? Anyone got a solution for this?

Regards


Solution

  • If you need to know how many entries your table has (in your case it's seems fixed to 100, but maybe it could grow), you can still do what you want:

    E.g. say your table on YOURPAGE depends on a datasource called Customers.

    1. Create a new Data item called CustomerCount, with just one field, called Count (integer).

    2. Its data source would be a sql query script:

    Select count(CustomerName) as Count from Customers

    1. on the page you are having the table on, add a custom property (say called Count of type integer)

    2. In the page attach event, set the property asynchronously with this custom action:

    app.datasources.CustomerCount.load(function() { app.pages.YOURPAGE.properties.Count = app.datasources.CustomerCount.count; app.datasources.Customers.query.pageIndex = @properties.Count / 25; app.datasources.Customers.datasource.load(); });

    I tried similar things successfully in the past.