Error with pagination

Hi,

   I have records in a table I have paginated it and displayed when I click on the save  button the records used to get updated to the backend  but here I am facing the problem if I am in 1st page only records in the 1st page will be saved to the backend if I am in 4th page records in 4th page will be saved to backend,All other records will not be saved in the databases.


Thanks,

Ronan T 

Do you have some screenshot to show us your problem?

Best Regards,

Nuno Pereira

Nuno Gonçalo Pereira wrote:

Do you have some screenshot to show us your problem?

Best Regards,

Nuno Pereira


Hi Nuno Gonçalo Pereira,

I am not suppose to share


Thanks

Ronan T


Hello Ronan,

Let me explain what is happening.

A TableRecords/ListRecords in the screen have an internal LIST /you can access it through the name of the table TableName.List). When the page is built in the server, this list will contain only the records it will show. 

So, if you have 100 hundred records in the database, and you are in page 1 and your Table/List Records is set to show 10 records per page, it will have only the first 10 records. If you move to the second page, it will store only the records from 11 to 20, and so on (don't remember if it is the Line Count or Line Count + 1 records).

In any case, in this list, you have only the records for that page.

So, you can't use it to save "everything back" to the database, and you will lose any changes made to this list if you move to a different page.

You can use some different approaches if you need to keep the changes and save to database only at the end, like keep a local List with the changed records. The challenge is that when you move to a page you need to check if the page will show records in this local list, and update the source of the TableRecords with the changes before showing in the screen.

Hope this helps.

Cheers.

Eduardo Jauch wrote:

Hello Ronan,

Let me explain what is happening.

A TableRecords/ListRecords in the screen have an internal LIST /you can access it through the name of the table TableName.List). When the page is built in the server, this list will contain only the records it will show. 

So, if you have 100 hundred records in the database, and you are in page 1 and your Table/List Records is set to show 10 records per page, it will have only the first 10 records. If you move to the second page, it will store only the records from 11 to 20, and so on (don't remember if it is the Line Count or Line Count + 1 records).

In any case, in this list, you have only the records for that page.

So, you can't use it to save "everything back" to the database, and you will lose any changes made to this list if you move to a different page.

You can use some different approaches if you need to keep the changes and save to database only at the end, like keep a local List with the changed records. The challenge is that when you move to a page you need to check if the page will show records in this local list, and update the source of the TableRecords with the changes before showing in the screen.

Hope this helps.

Cheers.

Hi,

Thank you,it was very helpful.

what if user made changes in different pages and click on save button then the last page will be updated right??

in this case how do we get to know where user made changes?


Regards,

Ronan T



Hi Ronan,

Yes, only the last, as all the other changes were lost and those records are not present in the TableRecords list.

Then the need to keep the changed records saved locally in a List so that at the end, you can update those records.

The alternative is to save a change as soon as it is made.

Cheers.

Eduardo Jauch wrote:

Hi Ronan,

Yes, only the last, as all the other changes were lost and those records are not present in the TableRecords list.

Then the need to keep the changed records saved locally in a List so that at the end, you can update those records.

The alternative is to save a change as soon as it is made.

Cheers.

Hi,

Could you please share the oml with example


Sorry Ronan, don't have one to share.
But basically, you create a list, and when the user changes a record, you add this record to the list.

In the end, this list will have all records the user changed, no matter the page where it is.

I'll leave the details to you to figure out ;)

Cheers

Hi Ronan,

In addition to what Eduardo wrote, it depends on your scenario what you would want to do in what case. If you have a paginated list that allows the user to change some values, and you do not want to commit those changes until they press a save button, and you want to allow them to go back and forth through multiple pages, there are several strategies, but it all depends on your set-up and your requirements (e.g. things get more difficult when you also want to allow the user to filter the results without losing changes).

If you describe your specific scenario, we might be able to suggest what we think is the best option for that specific scenario.

Kilian Hekhuis wrote:

Hi Ronan,

In addition to what Eduardo wrote, it depends on your scenario what you would want to do in what case. If you have a paginated list that allows the user to change some values, and you do not want to commit those changes until they press a save button, and you want to allow them to go back and forth through multiple pages, there are several strategies, but it all depends on your set-up and your requirements (e.g. things get more difficult when you also want to allow the user to filter the results without losing changes).

If you describe your specific scenario, we might be able to suggest what we think is the best option for that specific scenario.

Hi Kilian Hekhuis,

I have 68 records in the list and i have used pagination if i made changes in the 1st page on click of next button the value in the 1st page is getting refreshed because  we are refreshing the table in the pagination,onclick of next button i don't want the value in 1st page to be refreshed and onclick of submit button i want all the values to be posted to the databases but not the records in the perticular page .

Thanks,

Ronan T


Hi Ronan,

If the number of records is low, like the 68 you cite, I would create a Local Variable of the same type as the output of the Aggregate, and use that instead of the Aggregate directly. When paginating, assign the List of the Table Records to the Local Variable, then refresh the Table Records. The changes should be kept.

There's one possible caveat, the optimizer might detect that the Aggregate output is assigned to a List that is used in a Table Records, and decide to optimize the number of records anyway. If that's the case (you'd have to try out, I have no time now), use a ListDuplicate instead (and assign its output to the Local Variable).

Eduardo Jauch wrote:

Sorry Ronan, don't have one to share.
But basically, you create a list, and when the user changes a record, you add this record to the list.

In the end, this list will have all records the user changed, no matter the page where it is.

I'll leave the details to you to figure out ;)

Cheers

Hi Eduardo Jauch ,

I can save the changed values in a list then how can i compare the original list with the changed values i dont have any unique key here

Thanks,

Ronan T,