Subscribe Bookmark RSS Feed

Set column width with JSL?

pmroz

Super User

Joined:

Jun 23, 2011

Is there a way to set the display width of a column using JSL?  When I create a table, by default the columns are too wide.  I've tried playing around with set column width but it doesn't work.

I know that the column width is stored somewhere, because if I set the column widths manually, save the dataset, and then open it again, voila the widths are preserved.  I just don't know how to do it in JSL.

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
mattf

Community Trekker

Joined:

Jun 23, 2011

Solution

Hi:

dt = New Table( "test");

dt << New Column( "new");

column("new") << Get Field Width();  // default 10;

column("new") << Set Field Width(30);

column('new") << Get Field Width(); // now shows 30;

Show Properties(:new);  // log shows  a large number of properties, including field width;

Hope this helps,

-Matt

David_Burnham

Super User

Joined:

Jul 13, 2011

Solution

Peter

Version 12 has a new column message: Set Display Width.


Try( Column(dtCopy,"Viable cell density") << Set Display Width(120) ):

Try( Column(dtCopy,"Viable cell density") << Set Display Width(120) );

Dave

-Dave
5 REPLIES
mattf

Community Trekker

Joined:

Jun 23, 2011

Solution

Hi:

dt = New Table( "test");

dt << New Column( "new");

column("new") << Get Field Width();  // default 10;

column("new") << Set Field Width(30);

column('new") << Get Field Width(); // now shows 30;

Show Properties(:new);  // log shows  a large number of properties, including field width;

Hope this helps,

-Matt

pmroz

Super User

Joined:

Jun 23, 2011

Hi Matt,

That works if the column title is short.  However I have longer column names, and it appears that you can't set the field width to anything shorter than the column header.  For example:

dt = New Table( "test");

dt << New Column( "Curr Serious");

column("Curr Serious") << Get Field Width()// default 10;

column("Curr Serious") << Set Field Width(30);

column("Curr Serious") << Set Field Width(3); // shrinks the column but not to 3

ms

Super User

Joined:

Jun 23, 2011

For that situation you could use a short dummy name to force the apparent width to obey the field width.

dt = New Table( "test");

col=dt << New Column( "Curr Serious");

colname=col<<get name;

col << Set Field Width(30);

col<<set name("qqq");  // Any short unused temporary name

col << Set Field Width(3); // shrinks the column but not to 3

col<<set name(colname); // Reset column name, without changing width

However, controlling the table appearance by setting the field width property is not a general solution or comparable to manually changing column with by dragging the border. For instance, if the width is set to fewer characters than the cell content "###" or similar is shown instead of the value.

robust1972

Community Trekker

Joined:

Jan 15, 2014

hi, Matt

Can I set the column width to fit the longest title and cell content for few columns? Recently I tried to color the cells to draw wafer maps but I have to manually adjust the width of columns.

Thanks!

David_Burnham

Super User

Joined:

Jul 13, 2011

Solution

Peter

Version 12 has a new column message: Set Display Width.


Try( Column(dtCopy,"Viable cell density") << Set Display Width(120) ):

Try( Column(dtCopy,"Viable cell density") << Set Display Width(120) );

Dave

-Dave