-
Is it possible (maybe in a hackish way) to paginate the results of a custom query from MySQL ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 17 replies
-
Hey @poirazis! What do you mean by this? I have a custom MSSQL query which I use in a data provider and I'm able to paginate it just fine using the built-in paginate option limited to 50 rows per page. I didn't have to change my query at all. |
Beta Was this translation helpful? Give feedback.
-
Hi @poirazis Paginating the results from a custom query in MySQL is fairly straight forward. DataFetch your table. In my case it's a table of people names A-Z. DesignAdd a Form, Data Provider (Paginate query), Table. Give the page number field a name, and default value of 1. return ($("Form.Fields.Page")-1) * 5 multiply by your limit, in this case 5 Add conditional UI to the back button to prevent negative offsets. Define actions on the back button: Define actions on the next button: Hide the next button if the number of table rows is less than or equal to the limit minus one. You may want to be smarter here and have a second query to "look ahead" instead. Result |
Beta Was this translation helpful? Give feedback.
Hi @poirazis
Paginating the results from a custom query in MySQL is fairly straight forward.
Data
Fetch your table. In my case it's a table of people names A-Z.
Next create a query with a binding for LIMIT and OFFSET. I'm using a basic
select * from ...
but this should work for more complicated queries as well.Design
Add a Form, Data Provider (Paginate query), Table.
Under the table add a container to hold a back and next button, with a number field in between.
Give the page number field a name, and default value of 1.
Click to cog icon on the data provider, and add a JavaScript binding for the offset.
multiply by your limit, in this case 5
Add con…