BookmarkSubscribe
Choose Language Hide Translation Bar
Highlighted
kuannygoh
Occasional Contributor

unable to format data in table box when convert from data table

Hi all , 

I cant seem to format the data from the data table when convert to table box , the data does not change in percent as in data table . 

Here is the piece of code

 

//display result 
Data Table To Table Box = Function( {dt},
	{Default Local}, 
	
	tb = Table Box();
	For( i = 1, i <= N Cols( dt ), i++,
		col = Column( dt, i );
		colName = col << Get Name;
		lstValues = col << Get Values;
		type = col << Get Data Type;
		If( type == "Character",
			tb << Append( String Col Box( colName, lstValues ) ),
			tb << Append( Number Col Box( colName, lstValues ) )
		);
	);
	Return( tb );
	
);

Correct pic correct output.PNG

 

Wrong pic 

wrong converted.PNG

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: unable to format data in table box when convert from data table

When you specify:

lstValues = col << Get Values;

JMP is going to only retrieve the values in the column, not any information on the formatting.  To set the formatting, you need to pass the  "<< Set Format()" message to the Number Col Box().

Look in the Scripting Index for an example

     Help==>Scripting Index==>NumberColBox............Set Format

It gives a descripting and an example 

 

Jim
0 Kudos
1 REPLY 1
txnelson
Super User

Re: unable to format data in table box when convert from data table

When you specify:

lstValues = col << Get Values;

JMP is going to only retrieve the values in the column, not any information on the formatting.  To set the formatting, you need to pass the  "<< Set Format()" message to the Number Col Box().

Look in the Scripting Index for an example

     Help==>Scripting Index==>NumberColBox............Set Format

It gives a descripting and an example 

 

Jim
0 Kudos