Message Boards Message Boards

0
|
4546 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Tables with buttons to Delete rows

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.

Thanks

Jesus

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.

Jesus

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]], #]]]} & /@ 
   Range[5];
Position[t1[[All, 1]], 4]
Manipulate[Grid[t1, Frame -> All]]

Just in case it may be useful for anybody!

Jesus

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

Group Abstract Group Abstract