05-09-2016 09:36 AM
Hi. I have created a vi such that when a button is pressed data is added to a row. How to delete a unwanted row of the table with help of a button in front panel?
05-09-2016 10:12 AM
Hi,
the solution is quite simple.
You can remove the selected row by using property nodes. Using these, you have access to the data itself as you have by the local variables you already use, but you also can access other information about the control.
As you use a table, the hard part is to find which row has to be deleted. In my example below, i track which row the user selectes and delete this row if the user hits the "Delete" button.
To find the correct row, I use the invoke node which transforms the click position (in pixels) to a row/column information.
I hope that helps...
Kind regards
Felix
05-09-2016 10:56 AM - edited 05-09-2016 12:22 PM
(You probably need more than a button on the front panel, you also need to define the row to be deleted)
There is no need for expensive value property nodes. A table is nothing more than a 2D array of strings that you should keep in a shift register, then update the table indicator whenever the data in the array changes.
This reduces the problem to simple array operations on the 2D array. You know how to insert rows, so deleting a row is virtually the same.
Another option would be to use a multicolum liistbox instead of a table. Now you can very easily select a row and e.g. delete it using a double-click event, for example.
Also note that you have an immense amount of unecessary duplicate code to parse the string. How does the string look like? A direct translation of the current code would be to use a FOR loop and autoindex on an array of offsets. (It actually seems even more regular than that!).
05-09-2016 12:36 PM
Here's a quick draft of what I had in mind (inserts new row on top and deletes topmost row, respectively). Maybe it can give you some ideas.
Keep it simple!