104
Views
8
Comments
Solved
Pagination stops working after using a filter
Question


I have a page with several data filters. I set a maximum of 10 records to be displayed in the pagination, however, when I use any of the filters, the maximum number of 10 records does not work and a huge list appears. 

Furthermore, the filter only works on the first page of the pagination. 

2023-08-29 14-56-14
vn_perpetuo
Solution

Hi, thanks for everyone's help. 

I was doing the pagination and filtering as I observed in the outsystems documentation and with the help of the forums, but something was still going wrong. After observing everything carefully I realized that the error was in my DataAction. I was passing current.result to the values of my data action, so I changed it to local variables (which were the ones that received the filter), so the Refresh DataAction worked and maintained the pagination.

2023-09-13 13-47-19
Nuno Magalhães

Hello,

Can you share screenshots of the code?

2023-08-29 14-56-14
vn_perpetuo

Hi, i can share a little. 

Pagination-Filter1.png
Pagination-Filter2.png
2023-09-13 13-47-19
Nuno Magalhães

I can see that you're getting results not from a Query directly but from an API.

Do you have access to the API code? Because the issue might be there.

2023-09-06 07-26-35
Sudip Pal

Hey @vn_perpetuo ,

I have create a sample pagination demo where I am filtering the table based on Country Id(726).


I am attaching an OML. I hope this will help you!

Have a good day!

Thanks & Regards,

Sudip Pal

PaginationDemo.oml
2020-09-21 11-35-56
Sachin Waghmare

Hello @vn_perpetuo 

Here is the good post from @Kilian Hekhuis  where he had explained very well the pagination, sorting with example while data has been fetched by data action. Please refer this blog for your issue resolution.

https://itnext.io/paginating-sorting-and-filtering-data-from-a-data-action-f5cb997fdc60

Thanks,

Sachin

2023-10-06 11-44-47
Andre Valadares da Silva

Hi @vn_perpetuo hope You're well!

I think there's a misunderstanding on how to use the page variables (StartIndex and PageSize). Passing the updated values to the loop in Paginacao will probably not work because the data action doesn't seem to have been run again with the updated page values.

The updated page values have to be sent to the action that gets the data.

So, I understand you have a DataAction1 object attached to your screen. I guess this Data Action is getting its data from Get_Lote_Objeto Service Action.

What I guess you should be doing is:

  1. Create variables to hold the values of StartIndex and MaxRecords, with default values to 0 and whatever page size you want. That would define your first page settings
  2. Make sure your DataAction1 calls your Service Action (Get_Lote_Objeto) passing the values of those variables, along with your filters
  3. In the FiltrarOnClick you should do a refresh on your data action instead of calling Get_Lote_Objeto. Simply drag DataAction1 to your FiltrarOnClick action and remove the reference to Get_Lote_Objeto. That will refresh your DataAction bringing the first page result (remember it will be referencing your page variables with those default values)
  4. I also understand the action Paginacao is the one answering your pagination events. If so, this action should:
    • Update your page variables according to the pagination event (i.e. NewStartIndex)
    • Do  another refresh on your DataAction. This will run the action with the updated page values, bringing the new result page
    • Get and use the new page result from the data action


I hope I have been able to understand your question and been of some help.


Good luck and best regards!

2023-08-29 14-56-14
vn_perpetuo
Solution

Hi, thanks for everyone's help. 

I was doing the pagination and filtering as I observed in the outsystems documentation and with the help of the forums, but something was still going wrong. After observing everything carefully I realized that the error was in my DataAction. I was passing current.result to the values of my data action, so I changed it to local variables (which were the ones that received the filter), so the Refresh DataAction worked and maintained the pagination.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.