Hi buddies,
I hope you are fine.
I have one question regarding the Start Index and Navigation/Pagination widget.
I want to use the Navigation/Pagination widget to refresh my table records. I use the GetTransactions to fetch data and inside this action, I have the Aggregate GetTotalTransactions and an assign where I assign the data to the output TransactionList and Count. In the properties of aggregate GetTotalTransactions doesn't exist the Start Index property, only the Max Records property.
Usually, I use an Aggregate directly inside of the screen/block to fetch data and the aggregate has the property of Start Index and Max Records. In this situation, fetch data from other sources, the aggregate inside doesn't have the property of Start Index.
My question is: How can I get/calculate the start index and assign it to the table records?
I send my oml file attached.
Thanks in advance.
Kind regards,
FC
Hello Fábio,
Hope you're doing well.
Checking on your code, you have GetTotalTransactions Aggregate inside GetTransactions Data Action. Why don't you simply execute the Aggregate (Fetch Data from Database) directly instead of using a Data Action (Fetch Data from Other Sources)?
If you do this, you will have access to both Start Index and Max. Records properties from the Aggregate and you can implement a Pagination like described in here. You had implemented like this in your TransactionCategories screen.
If you want to use a Data Action (Fetch Data from Other Sources) and implement a Pagination, you will still be able to do that, but you have to implement an additional logic.
Please refer to attached OML file with these changes.
Hope that this helps you!
Rui Barradas
While I understand this is the right answer... it seems like it shouldn't be. What a clunky way to do things. I sincerely hope the team is looking into improving this, specially because there are some things that cannot be done if not inside a Data Action (like use the platform's DatabaseConnection_SetConnectionStringForSession to dynamically connect to different databases on the fly).
Hello again Fábio,
In terms of performance, I would suggest for you to use Aggregates whenever is possible. The OutSystems Platform has optimizations for Aggregates, such as optimizations for the number of fields to be retrieved (based on the fields that you are actually using).
If you do this Aggregate inside a Data Action, then the Platform can't optimize it. So I suggest to use an Aggregate in this scenario.
Rui,
Yeah, I understand your question :).
I know how can I use the Navigation/Pagination widget with the Aggregate (Fetch Data from Database) directly but I don't know how can I use the Navigation/Pagination widget with Data Action (Fetch Data from Other Sources). So I tried to do that and I couldn't do it.
What is the best solution in terms of performance?
Thanks for your excellent explanation.
I implemented what you did and works perfectly.
Best regards,
I understand what you are saying.
I'll do it.
Thank you so much.
Have a nice day!