Subscribe Bookmark RSS Feed

add rows to a tablebox with a colspanbox

vince_faller

Super User

Joined:

Mar 17, 2015

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.   

1 ACCEPTED SOLUTION

Accepted Solutions
Justin_Chilton

Joined:

Aug 27, 2015

Solution

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
txnelson

Super User

Joined:

Jun 22, 2012

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

    support@jmp.com

Jim
vince_faller

Super User

Joined:

Mar 17, 2015

@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);
);
Justin_Chilton

Joined:

Aug 27, 2015

Solution

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