Independent Development
How to get the original data in Table components in Retool
Error
I create an icon column in Table components, and add some script to its click handle. In this case, here is a param currentRow that can be used, which contains the data of the row in which the icon was clicked.
But it contains mapped values, not the original one. This can really result in errors sometimes.
Solution
Using Table1.data can access to the original data. It is an array.
Documents said there is a param I which means the index of the row, but it doesn’t work in my case. Not sure why.
Instead, I used a method: Create a column, set its key to index and value to {{ i }} (well, this can work), and use as the index like this: Table1.data[currentRow.index]. Then hide this column.
Tricky, but it works well.
Main Site(Under building)
Related Platforms
(Github Issues) / (Notion) / (Blog)
Advertisement
(A website to optimize your resume and to boost your career: Nonpareil.me)
独立开发
如何获取Retool中Table组件的源数据
问题
在Retool中,我在一个Table组件内设置了一列显示一个图标,点击这个图标会触发脚本。这时有一个默认参数可以调用:currentRow。它包含了当前这一行的数据。
不过这是经过map后的数据。Retool有时会有一些默认的数据处理过程,如果不注意,这会造成很大问题。
解决方案
使用Table1.data可以获取到源数据。这是一个数组。
文档说有一个默认参数I,就是当前行的索引,不过在我这里不好用。不知道为什么。
所以我用了另外一种办法:创建一列,把它的key值设置成index,value值设置成{{ i }}(在这里能用了)。然后在脚本里调用时这样写:Table1.data[currentRow.index]。最后再把这一列隐藏起来。
很麻烦而且冗余的方法,不过能用。
主站(建设中)
[Nonpareil Me]{https://nonpareil.me}
相关平台
(Github Issues) / (Notion) / (Blog)