Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- add rows to a tablebox with a colspanbox

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 28, 2017 8:43 AM
(3009 views)

It may just be too early, but am I doing something wrong when trying to add rows to a tablebox() that makes use of a colspanbox()?

```
Names Default to here(1);
new window("Test",
tb = tablebox(
)
);
things = {"Thing1", "Thing2"};
for(i=1, i<=nitems(things), i++,
tb << append(
Colspanbox(things[i],
NumbercolEditBox("X", {1}),
NumberColEditBox("Y", {2})
)
)
);
tb << add row({1, 2, 3, 4});
```

*Edit* insert row and delete row also don't seem to work.

Vince Faller - Predictum

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

In JMP 13, the N Items function can return the number of Display Boxes within a parent Display Box. Because of this, you can get the number of Col Span Boxes within the TableBox. If you loop through each of the Col Span boxes, you can then get the number of Number Col Edit Boxes within each Col Span Box in order to loop through and add values to them.

Below is a workaround that uses nested for loops to get references to each of the Number Col Edit Boxes. Also, I used Add Element instead of Get, Insert Into and Set as it saves a few steps.

```
Names Default To Here( 1 );
New Window( "Test",
tb = Table Box(
)
);
things = {"Thing1", "Thing2"};
For( i = 1, i <= N Items( things ), i++,
tb << append(
Col Span Box(
things[i],
Number Col Edit Box( "X", {1} ),
Number Col Edit Box( "Y", {2} )
)
)
);
values = {{1, 2}, {3, 4}};
For( i = 1, i <= N Items( tb ), i++,
For( k = 1, k <= N Items( tb[i] ), k++,
tb[i][k] << add element( values[i][k] );
)
);
```

Justin

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: add rows to a tablebox with a colspanbox

I replicated your findings.....looks like it is time to go to

support@jmp.com

Jim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: add rows to a tablebox with a colspanbox

I did find a workaround, but yeah add row() doesn't seem to work with colspanbox.

```
nthings = nitems(tb << Get);
values = {{1, 2}, {3, 4}};
for(i=1, i<=nthings, i++,
l1 = tb[i][1] << Get;
l2 = tb[i][2] << Get;
insert into(l1, values[i][1]);
insert into(l2, values[i][2]);
tb[i][1] << Set(l1);
tb[i][2] << Set(l2);
);
```

Vince Faller - Predictum

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

In JMP 13, the N Items function can return the number of Display Boxes within a parent Display Box. Because of this, you can get the number of Col Span Boxes within the TableBox. If you loop through each of the Col Span boxes, you can then get the number of Number Col Edit Boxes within each Col Span Box in order to loop through and add values to them.

Below is a workaround that uses nested for loops to get references to each of the Number Col Edit Boxes. Also, I used Add Element instead of Get, Insert Into and Set as it saves a few steps.

```
Names Default To Here( 1 );
New Window( "Test",
tb = Table Box(
)
);
things = {"Thing1", "Thing2"};
For( i = 1, i <= N Items( things ), i++,
tb << append(
Col Span Box(
things[i],
Number Col Edit Box( "X", {1} ),
Number Col Edit Box( "Y", {2} )
)
)
);
values = {{1, 2}, {3, 4}};
For( i = 1, i <= N Items( tb ), i++,
For( k = 1, k <= N Items( tb[i] ), k++,
tb[i][k] << add element( values[i][k] );
)
);
```

Justin