I have attempting to set up a table connected to a database where the table shows a fixed number of items, with pagination below, and where selecting any row in the table will cause information to show up elsewhere on the webpage. I have setup all the basics that make this work; however, I have run into a cascade of problems and have finally come to a dead end where I see no solution.
The following relevant code I use is shown here:
$w.onReady(function () {
$w(“#DatabaseName”).onReady( () => {
let itemData = $w(“#DatabaseName”).getCurrentItem();
$w(“#DatabaseName”).onCurrentIndexChanged( (index) => {
});
});
});
———————
ATTEMPT #1
I used only the Wix interface (without writing additional code) to set the table as follows:
Table Settings:
- “Resize Table Height” set to “Automatically”
- “Apply Pagination” deactivated
Database Setting: - “Number of items to display” set to 20
PROBLEM #1
Automatic table height does not work.
If you set “Resize Table Height” to “Automatically” the table will display every item in the database, not just the maximum number of items selected by the “number of items to display” setting in the Dataset.
This problem is noted here: https://www.wix.com/corvid/forum/community-discussion/tables-databases-and-pagination-bars
No solution is offered to fix this problem.
PROBLEM #1.1
With these same settings, though all items in the Dataset are displayed, the system will automatically jump to row 1 when a row outside the “Number of items to display” maximum is selected.
Think of a 60 row table as being made up of four “row sets” 1-20, 21-40, 41-60. The first selection outside any row set will cause the entire table to jump to row 1, but any subsequent selection within_that_set will work properly.
i.e. with “Number of items to display” set to 20, selecting row number 1-20 works properly, but selecting row number 25 causes the table to jump immediately to the top of the table. If you then immediately scroll down and select any row between 21 and 40 everything works ok. Selecting outside the 21-40 row set, however, will cause the scroll to top problem again.
This problem is noted here: https://www.wix.com/corvid/forum/community-discussion/retrieve-data-from-selected-table-row and here: https://www.wix.com/corvid/forum/community-discussion/how-to-prevent-table-from-scrolling-to-the-top-when-a-row-is-selected
SOLUTION:
No solutions at the above links appeared to work, so I opted to turn on pagination. However, turning on pagination caused problem #2 noted below.
——————
ATTEMPT #2:
In an attempt to fix the first issue I set the table up to show a fixed number of items using the built in pagination option. I used only the Wix interface (without writing additional code) to set the table as follows:
Table Settings:
- “Resize Table Height” set to “Manually”
- “Apply Pagination” activated
- “Rows Per Page” set to 20
Database Setting: - “Number of items to display” set to 20
PROBLEM #2:
This resulted in a situation where the selection of the first page of items works properly (it properly pulls data from that row and displays it elsewhere); however, if you go to page 2 (or greater) and select row #2 (or greater) the system will “get” and thus display the information from page 1 of the selected row instead of the information from the page you are on.
i.e. Go to page 2 of table, select row 5, the displayed information will show the item from page 1 row 5. The only row this will work correctly on page 2 (or greater) is row 1.
This problem is noted here: https://www.wix.com/corvid/forum/community-discussion/resolved-pagination-table-bug
Though listed as “resolved” there is no solution and it appears to me to remain an unfixable bug.
——————
I am brand new to Wix and have run into a huge number of issues but I have figured out how to fix all of them until now. I hope someone can offer a solution to my conundrum here.