BookmarkSubscribe
Choose Language Hide Translation Bar
Highlighted
gkrjqu7
Occasional Contributor

Is there a function that can replace the entire table inside a table box?

I have a empty/default table box poped up, and I wanted to replace the entire table box using the script below. Is there a way to update [table box] with 

 

This script I am using now is tedious:

button box("UPDATE",
    dtmain = Open(filename, invisible);
    tb << delete row( 1 );
    tb << delete row( 1 );
// 50 lines of delete row()
tb << insert row( 1, {"a", 1} ); tb << insert row( 1, {"b", 2} );
// 50 lines of insert row()  );

Thanks in advance:)

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Is there a function that can replace the entire table inside a table box?

I have found it that it is easier to delete and replace the table, rather than updating.  The simple script below illustrates that methodology

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

New Window( "The Table",
	vlb = V List Box(),
	theButton = Button Box( "UPDATE",
		Try( theTable << delete );
		theList = {};
		Insert Into( theList, dt:Name[Random Integer( 1, 40 )] );
		Insert Into( theList, dt:Name[Random Integer( 1, 40 )] );
		theTable = Table Box( String Col Box( "Name", theList ) );
		vlb << append( theTable );
	)
);

// Initialize the table
theList = {};
Insert Into( theList, dt:Name[Random Integer( 1, 40 )] );
Insert Into( theList, dt:Name[Random Integer( 1, 40 )] );
theTable = Table Box( String Col Box( "Name", theList ) );
vlb << append( theTable );

Jim
1 REPLY 1
txnelson
Super User

Re: Is there a function that can replace the entire table inside a table box?

I have found it that it is easier to delete and replace the table, rather than updating.  The simple script below illustrates that methodology

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

New Window( "The Table",
	vlb = V List Box(),
	theButton = Button Box( "UPDATE",
		Try( theTable << delete );
		theList = {};
		Insert Into( theList, dt:Name[Random Integer( 1, 40 )] );
		Insert Into( theList, dt:Name[Random Integer( 1, 40 )] );
		theTable = Table Box( String Col Box( "Name", theList ) );
		vlb << append( theTable );
	)
);

// Initialize the table
theList = {};
Insert Into( theList, dt:Name[Random Integer( 1, 40 )] );
Insert Into( theList, dt:Name[Random Integer( 1, 40 )] );
theTable = Table Box( String Col Box( "Name", theList ) );
vlb << append( theTable );

Jim