How to add data in table through textfield component in Perspective?

I am trying to add data in table component through text field component in perspective. Is there any way to update data through user input in text field?

I would add a value change script on the textField that appends to the data property on the table with a new row. The other option is to have a button next to the textField that appends whatever is in the textField to the table.

1 Like

You might want to think through what you are trying to achieve.

  • When does the text get added? (What user action triggers the addition of the data to the table and the clearing of the text field? Or do you want the text field to have all text selected so it can be edited for the next row?)
  • What is going to happen to the data when the view is closed? i.e., If you want to store the data in a database then you need to save it to the database and then have the table update by a database query binding.

Think it through. Then edit your question.

2 Likes

These are the following steps I am trying to do:

  1. The user inserts data into the textfield component and clicks the add button. The textfield will be cleared then. The data will be stored on the dataset memory tag which is binded with a table component.

  2. When all the data is inserted, the user will finally click on the submit button that will send all the data to a database (to save it).

  3. The dataset memory data will be cleared to add more data. The database will be updated for new incoming data.

Now what I would like to ask is that instead of textfield component I need to insert data in the table cell which will populate the dataset memory tag. How it would be possible?

  1. It would be more sensible to edit in the table cell directly. You would need a + add row button and some code to add a row to the table data. The Enter key would trigger an onEditCellCommit event and you write the code in there to update the table data.
  2. You would need to add a script to a button onClick event. That would then need to loop through all the rows in the table and run an SQL INSERT.
  3. The onClick code would also clear the table.
1 Like