Table Record number is not accurate


Hi All,

I have a Table Record Widget with the following settings:

1. Source Record List is a 'List' with 40 items

2. Line Count by default is 10 but this is configurable by a dropdown list

3. With Pagination Widget


Problem

Lets say the table record has 40 records from the list and Line count is set to 10 per page. If I select the record 19 in page 2 the ImagesTableRecords.List.CurrentRowNumber value is 9 and not 19.


I need to get the accurate row number because I will use it to remove the item in the list then refresh the TableRecord. Thanks


Hi Paul, when you're on page 1 the platform stores the first 10 records from your source record list on the TableRecords list, when you navigate to the second page, it replaces those 10 records with the next 10 on your source record list, so your table records always has only "Line Count" amount of records.

Hi Paul,

The TableRecords only holds the records you actually see on the Screen, so the reported CurrentRowNumber is acurate - it's just not what you expect.

In general, a Table Records reflects what's in the database. Therefore, manipulating the list is not a typical use case. What's typical, is that when you select a certain row, you modify the contents in the database, then refresh the query that's bound to the Table Records, then refresh the Table Records.

In fact, when you refresh the Table Records, it's rebound to the original Source List. So even if you manage to delete from the Table Records Source List the right item, after an Ajax Refresh it's there again.

If you show data that's not bound to an Entity, you need to manipulate the Source List, then refresh the Table Records to reflect the changes. To find the right record, you may use a ListIndexOf.

Solution

You can also use something like 

List_Navigation_GetStartIndex(YourTableRecords.Id, True) + YourTableRecords.List.CurrentRowNumber

This should give you the value you're looking for.

Solution

Note: that's the index into the Source List.

Hi Paul,

To remove an item from the database from a list, you don't need to get the rownumber/index of the item. Usually the records that are being displayed in your TableRecords list will have an Id-field. When you call a screen action from a record in the list (e.g. a link 'Delete'), then this will be the 'Current' record (TableRecords.List.Current.<EntityName>.Id). This way you've access to the ID and can delete the record with that ID from the database. After that you refresh the source list and refresh the TableRecords widget to display the current situation.


Regards,

Lennart

Hello Paul

Only to add to the  solution of Lennart, that I fully agree and you must mark the solution.

To delete a item form Database with the Id, use the (crud) action Delete<EntityName> with the id as parameter


Best Regards


Except Paul didn't say he was manipulating a list fed from the database... I infer he's using a normal list from his question.

Lennart Kraak wrote:

Hi Paul,

To remove an item from the database from a list, you don't need to get the rownumber/index of the item. Usually the records that are being displayed in your TableRecords list will have an Id-field. When you call a screen action from a record in the list (e.g. a link 'Delete'), then this will be the 'Current' record (TableRecords.List.Current.<EntityName>.Id). This way you've access to the ID and can delete the record with that ID from the database. After that you refresh the source list and refresh the TableRecords widget to display the current situation.


Regards,

Lennart


Hi Lennart, I am not deleting from the database. The List data items comes from AWS S3. I was able to delete the file using the Object key in provided by S3, my problem is removing the actual item in the list object. The only way to do that is to delete is by Position using the List Remove widget.

Afonso Aguas wrote:

You can also use something like 

List_Navigation_GetStartIndex(YourTableRecords.Id, True) + YourTableRecords.List.CurrentRowNumber

This should give you the value you're looking for.


Thank You Afonso, this resolved my issue. :)

Good to see that you were able to solve the issue. 

I think Afonso's solution will work just fine. As an alternative you could also use the system action 'ListIndexOf' to get the row number based on a condition, e.g. the Object key, and use that to remove the item.