BookmarkSubscribe
Choose Language Hide Translation Bar
vince_faller
Super User

add rows to a tablebox with a colspanbox

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
0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions

Re: add rows to a tablebox with a colspanbox

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
txnelson
Super User

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
0 Kudos
vince_faller
Super User

Re: add rows to a tablebox with a colspanbox

@Justin_Chilton ? 

 

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
0 Kudos

Re: add rows to a tablebox with a colspanbox

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