Message Boards Message Boards


Tables with buttons to Delete rows

Posted 9 years ago
3 Replies
1 Total Likes

Friends from the this group. I have been trying to create a Table which includes numerical data and a button so that the user may have buttons to delete the specific row. My first attempt was this one:

t1 = Table[{1, 2, 3, 4, 5, Button["X", t1 = Delete[t1, 1]]}, {i, 5}];
Manipulate[Grid[t1, Frame -> All]]

This deletes fine the first row of the table every time a delete button is pressed. Nevertheless I couldn't do it for specific row. I have tried many thinks, among them, this one

t1 = Table[{1, 2, 3, 4, 5, Button["X", t1 = Delete[t1, i]]}, {i, 5}];
Manipulate[Grid[t1, Frame -> All]]

There is a error message "The expression i cannot be used as a part specification. Use Key[i] \ instead" I assume because inside the button function "i" does not have a value. Is it possible to pass "i" as a parameter to the Button ?? Is there a way around to do this.



3 Replies

Henrik, Thanks. My code is part of a larger program and to publish it here I cut it off... too much as I realise now. Best regards.


Hi Jesus,

I think in your own reply the last line is not correct:

'Manipulate' expects a list as second argument.

Maybe it rather should read:

Dynamic @ Grid[t1, Frame -> All]

Regards Henrik

POSTED BY: Henrik Schachner

I solved my problem

t1 = {#, 2, 3, 4, 5, 
     Button["X", t1 = Delete[t1, Position[t1[[All, 1]], #]]]} & /@ 
Position[t1[[All, 1]], 4]
Manipulate[Grid[t1, Frame -> All]]

Just in case it may be useful for anybody!


Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract