Icon functionality in perspective table

we have edit icon column in a table ,I want to do functionality on table row like when we click the edit icon the particula row data will be editable. and for remove it will remove the particular row data

Removing should be easy, but editing might not be possible because I don't think there's a way to tell the Table to enter editing mode via scripting.

Removal will require a few things (this assumes a data structure which is a list of dictionaries - DataSets will need to modify the Message Handler Script slightly):

  1. The View which contains your "delete" icon accept a param with a key of rowIndex.
  2. The Table have a configured Message Handler with a name of your choosing; my later script will use a name of "DELETE_ROW".
  3. The onClick Event of the Icon should have a Script Action configured to invoke the Message Handler.

onClick Event Script Action:

system.perspective.sendMessage("DELETE_ROW", payload={"rowIndex": self.view.params.rowIndex, scope="page"}

Table Message Handler Script:

del self.props.data[payload["rowIndex"]]

on click event script - having some missing term .... or some error mismatching type on Scope = page

Please supply the exact error message.

# never assume my code is golden - this is all just me typing into the forums
system.perspective.sendMessage("DELETE_ROW", payload={"rowIndex": self.view.params.rowIndex}, scope="page")

1 Like

can you elaborate the point 1 - View which contains your "delete" icon accept a param with a key of rowIndex ?

In the View which will contain your Icons, select the named View node (not the root node) in the Project Browser. Now, in the Property Editor, add a new property into the PARAMS category. Rename the key of this property to rowIndex (case-sensitive). This View will now accept a parameter of rowIndex from any source which uses this View. I recommend a default value of empty string for your use case.

To use this View within the Table, you need to must configure the render prop of the column configuration to be "view", and you must then configure the viewPath prop of the column configuration to be the path of the View you just made which contains your Icons.