Col list box() does not respect data table referenceUsing JMP 14.1:
I want people to select two data tables and then display the columns in those datatables in two col list boxes. However when I set the columns in the boxes, JMP will only set the columns from the active data table and will not respect the data table argument. Any suggestions?
Here is a quick example of the wrong behavior:
dt = New Table( "Table 1",
Add Rows( 0 ),
Compress File When Saved( 1 ),
New Column( "Column 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
),
New Column( "Column 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
),
New Column( "Column 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
)
);
dtNew = New Table( "Table 2",
Add Rows( 0 ),
Compress File When Saved( 1 ),
New Column( "Column 4",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
),
New Column( "Column 5",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
),
New Column( "Column 6",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
)
);
new window("Column renamer",
h list box(
Panel box("Source table",
SourceBox = Col List Box(dt,All)
),
Panel box("Destination table",
DestBox = Col List Box(dtnew,All),
),
)
);This results is:

The expected result is that in the left list the columns 1,2,3 are shown since those are the names in the first table. Instead it is showing the second table (the last created and as such the active table) twice.
Re: Col list box() does not respect data table referenceUnderstood! You can do a similar thing with 'ColListBox()' if you prefer:
Names default to here(1);
ListOfOpenTables = sort list(Get Data Table List());
updateCLB =
Expr(
Try(clb << delete);
thisTable = (tlb << getSelected)[1];
CMD = Expr(nw << Append(clb = ColListBox(DataTable(tableTBD), All, maxSelected(1), clbAction)));
SubstituteInto(CMD, Expr(tableTBD), Eval(thisTable));
CMD;
);
clbAction =
Expr(
Speak("Column "||(clb << getSelected)[1]||" was selected.");
);
nw = NewWindow("Test", tlb = ListBox(ListOfOpenTables, maxSelected(1), updateCLB));
Re: Col list box() does not respect data table referenceYeah, with using a standard list box I got it to work, but it doesn't look like column selection dialogs that JMP normally uses. And it doesn't show column grouping from your data table. Hence I would like to implement it with the col list box
Re: Col list box() does not respect data table referenceSorry Paul, I didn't have the time to understand the nuances of what you are trying to do.
But here's an old code snippet that may get you closer (not using 'ColListBox()'):
Names default to here(1);
ListOfOpenTables = sort list(Get Data Table List());
updateCLB =
Expr(
thisTable = (tlb << getSelected)[1];
CMD = Expr(cols = DataTable(tableTBD) << getColumnNames("String"));
SubstituteInto(CMD, Expr(tableTBD), Eval(thisTable));
CMD;
clb << setItems(cols);
);
clbAction =
Expr(
Speak("Column "||(clb << getSelected)[1]||" was selected.");
);
nw = NewWindow("Test",
tlb = ListBox(ListOfOpenTables, maxSelected(1), updateCLB),
clb = ListBox({"Pick a table above"}, maxSelected(1), clbAction)
);Re: Col list box() does not respect data table referenceHi Ian, Thanks for your help but indeed it does not solve my problem. Here is a bigger code snippet of what I'm really trying to do. So you select two different tables from the open tables and as you select a different table the column list below it populates with the columns from the selected tables:
Names default to here(1);
ListOfOpenTables = sort list(Get Data Table List());
ColumnWidth = 300;
new window("Column renamer",
h list box(
Panel box("Source table",
v list box(
FirstDT = List box(ListOfOpenTables, maxSelected(1), width(ColumnWidth),
dt = Data Table((FirstDT << get selected())[1]);
SourceBox << Set items(Data Table((FirstDT << get selected())[1]) << Get Column Names("String"));
),
SourceBox = Col List Box(,nlines(40), width(ColumnWidth),
OldCounter << set text(char(n items(SourceBox << get selected())) || " Columns selected");
dt << Select columns(SourceBox << get selected());
),
OldCounter = Text Box("")
)
),
Panel box("Destination table",
v list box(
SecondDT = List box(ListOfOpenTables, maxSelected(1), width(ColumnWidth),
dtnew = Data Table((SecondDT << get selected())[1]);
DestBox << Set items(Data Table((SecondDT << get selected())[1]) << Get Column Names("String"));
),
DestBox = Col List Box(,nlines(40), width(ColumnWidth),
NewCounter << set text(char(n items(DestBox << get selected())) || " Columns selected");
dtnew << Select columns(DestBox << get selected())
),
NewCounter = Text Box("")
)
),
Panel box("Actions",
v list box(
button box("Change column names",DoTheWork),
button box("Undo",Undo)
)
)
)
);Re: Col list box() does not respect data table referenceNot answering your real question, but this works (JMP 14.2 on a Mac):
dt = New Table( "Table 1",
Add Rows( 0 ),
Compress File When Saved( 1 ),
New Column( "Column 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
),
New Column( "Column 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
),
New Column( "Column 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
)
);
dtNew = New Table( "Table 2",
Add Rows( 0 ),
Compress File When Saved( 1 ),
New Column( "Column 4",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
),
New Column( "Column 5",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
),
New Column( "Column 6",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [] )
)
);
new window("Column renamer",
h list box(
Panel box("Source table",
SourceBox = Col List Box(DataTable( "Table 1"),All)
),
Panel box("Destination table",
DestBox = Col List Box(DataTable( "Table 2"),All),
),
)
);