I have been trying to make a table column editable but it does not seem to work. The table is attached to a named query. Also how do I hide a column?
If you want to be able to make a table column editable right click on the table and select on Customizers > Table Customizers > Editable and check whatever columns you want to make editable. The same applies to hiding columns. It can all be done in the Table Customizer.
To make a cell editable in Perspectiveās table component, you need to make the columnās value an object, rather than a literal value; see the example in the seeded table component - the āCityā for see @anjorogeās comment below.Helsinki
is a static string, but for Folsom
itās an object with (in this case) three keys. The two vital ones are the value
(āFolsomā) and the editable
flag (set to True).
However, unfortunately at present table cell editing hasnāt been implemented - the Vision concept of āExtension functionsā is going to be carried over in some respect.
I believe the above solution is for vision components but for perspective components you can make all the cells of a column editable by configuring the column config (columns prop). You can also make individual cells editable, which overrides whatever is configured in the column config.for information you can go to the below link.
http://forum.inductiveautomation.com/t/feedback-new-perspective-table/
it looks like the feature has not been implemented yetā¦ I tried the following settings and I can not edit the columns yet. I tried it on 2 columns.
Hi,
Column configs control the ordering, number of columns displayed, what columns are displayed, and an individual columns configuration. Thereās no way to know what column config is associated with what data column unless you specify this using the configs āfieldā prop. The āfieldā prop should correspond to the key in the key value pair of your data, assuming it is a dataset or an array of objects. For example, [{ city: āFolsomā, state: āCaliforniaā },ā¦] would require that the āfieldā prop of the column config for your city column be ācityā in order to associate the column config with the data.
Hope that helps.
-Yousuf
But I am still not clear about how to make the column editable.
Table editing isn't yet implemented.
I got it. Any ETA on when it will be implemented? I am also trying to render a view in a cell using the viewpath property and it does not seem to work either
Try linking the column config with the desired column using the āfieldā prop, as I suggested earlier.
Editing a cell is currently possible, however, we currently do not have anything implemented to handle these changes. Edits are currently being logged to the browser console as an example of what will become available. We are currently working on implementing extension functions in order to handle these edits, which you can expect soon.
Please refer to http://forum.inductiveautomation.com/t/feedback-new-perspective-table for the latest unofficial docs, news on the table component, and the answer to many of your questions.
-Yousuf
I donāt know if thereāll be an easier way to do this but hereās my solution thus far. To enable editing for select columns Iāve converted the incoming data (a dataset thatās the result of a query) to a list of dictionaries. each row is: {ācolumn nameā:{āvalueā: 10,āeditableā:True}.
# convert dataset to dict
editableCols = ["firstName","lastName"]
ds = value
colNames = ds.getColumnNames()
d = []
for i in range(ds.rowCount):
rowDict = {}
for col in colNames:
editable = False
if col in editableCols:
editable = True
rowDict[col] = {"value":ds.getValueAt(i,col),"editable":editable}
d.append(rowDict)
return d
Running on Version: 8.0.0 (b2019040718)
Quick workaround:
Go to your table, left-click, Configure Event... > Component Events > onEditCellCommit
Adapt the following script according to your needs, in my case I was toggling a boolean column called 'PRINT':
tbl = self.props
state = tbl.selection.data[0].PRINT == 'true'
tbl.data = system.dataset.setValue(tbl.data, tbl.selection.selectedRow, tbl.selection.selectedColumn, not state)
I haven't tested it thoroughly but it seems to be working fine. Remember to leave the option editable turned on (table.props.columns.editable).
I am experiencing the same issue as described above, but with version 8.1.11 (b2021101912).
Iāve attempted to drop a new table onto a view and change nothing (e.g. leave all settings as default and sample data intact).
When I try to edit the first cell (Folsom), which already has editing enabled, any changes made to the cell value fail to commit.
I ended up adding an onEditCellCommit script similar to @apereira above (except using dictionary instead of dataset):
tbl = self.props
value = event.value
tbl.data[tbl.selection.selectedRow][tbl.selection.selectedColumn] = value
Has anyone else experienced this issue in 8.1.11?
What makes you think the script is optional? (It isnāt.) Maybe the docs need to be more clear.
Optionally, use event.row
for row index & event.column
for column name:
self.props.data[event.row]['value'][event.column] = event.value
Note that you may need to omit ['value']
if it is not in your dataset.