I have a table that uses the dataFetcher property to dynamically populate its content according to a filter that the user selects. The table contents are cached in memory on the browser using wix local storage. When the user changes the filter dropdown, I apply the new filter and call $w(“#table1”).refresh(), which causes the table to call the data fetcher, which returns the new set of rows. Works great. Only one problem, which is my second column called ID (field id).
This field does not seem to refresh. The underlying data definitely does change. The id attribute on each row’s object is definitely different. However, each time I change the filter and refresh the table, the list of ids remains the same. I declare an onRowSelect handler for the table and the event.rowData.id attribute is the wrong one, not the one corresponding to the underlying data. So the table does not seem to ever refresh its id list, yet all the other columns refresh just fine.
This seems to be purely a wix display issue, and the fact that the column is called “id” is likely to be the cause - it’s probably a use case that QA never tried testing. Is there a way to post a defect for Wix? This is not a feature request…
Plus, if you have already assigned an id to your data, then you can’t change it again.
ID (_id)
Text
A unique identifier for the item. You can assign the ID a value when you import new data from a CSV file. Otherwise the ID is a random UUID.
Using Corvid by Wix you can also assign the ID a value when adding items with the Data API.
It clearly states there too that if you have alrrady assigned a value to ID then you can’t change it again.
The insert() function adds the following properties and values to the item when it adds it to the collection:
_id: A unique identifier for the item with collection, if the item does not include one. You can optionally provide your own ID. Once an ID is assigned to an item it cannot be changed.
Insert an item with a specified ID into a collection
I’d agree with your assessment if we were talking about a backend database collection. In this case, I’m talking about a table display that does not have an underlying database - it’s populated dynamically using the data fetcher capability for table displays. No collection involved since all my data comes from an external provider. Of course it is likely that the defect creeps in because of the requirement to link Wix collections to tables. Table displays are “dual purpose” and the code needs to reconcile both scenarios.
Anyway, changing the column name to idx fixes the problem. Perhaps wix should warn about using column “id” in table displays? There are probably a bunch of issues in here.