如何动态列出所选数据表的列名?你好呀,
我正在尝试创建一个像Tables-Join 这样的窗口,它的第二个大纲框可以在左上角的列表框中动态列出所选数据表的列名。
提前致谢。
脚本编写视窗Re: 如何动态列出所选数据表的列名?你好,
您可以使用如下代码来执行此操作。 当您打开几个数据表时,尝试运行此代码。
干杯,
布雷迪
Names Default To Here( 1 );
//get a list of window names
windows = Window() << get window title;
//remove ones that are not data tables--need to start at back of list, because its length will change as we delete items
For( i = N Items( windows ), i > 0, i--,
If( (Window( windows[i] ) << Window Class Name) != "DataTable",
Remove From( windows, i )
)
);
//make a dialog window
nw = New Window( "Sample",
vlb1 = V List Box(
lb1 = List Box(
windows, //populate the listbox with data table names
//here is the script that runs each time someone clicks in the top box
//delete the current column list box, if it exists
Try( lb2 << delete );
//append a new col list box, with all columns of the data table selected in the listbox
vlb1 << append( lb2 = Col List Box( Data Table( (lb1 << get selected)[1] ), all ) );
)
)
);


Re: 如何动态列出所选数据表的列名?感谢你的回复。 我用“过滤器列选择器”替换“列列表框”,它没有按预期工作,每次选择表时都会留下一个红色三角形,列列表不会相应地更新。
它是如何通过使用“过滤列选择器”来完成的?
Names Default To Here( 1 );
//get a list of window names
windows = Get Data Table List();
/*remove ones that are not data tables--need to start at back of list, because its length will change as we delete items
For( i = N Items( windows ), i > 0, i--,
If( (Window( windows[i] ) << Window Class Name) != "DataTable",
Remove From( windows, i )
)
);
*/
//make a dialog window
nw = New Window( "Sample",
vlb1 = V List Box(
lb1 = List Box(
windows, //populate the listbox with data table names
//here is the script that runs each time someone clicks in the top box
//delete the current column list box, if it exists
Try( lb2 << delete );
//append a new col list box, with all columns of the data table selected in the listbox
vlb1 << append( lb2 = Filter Col Selector( Data Table( (lb1 << get selected)[1] ), all ) );
)
)
);

Re: 如何动态列出所选数据表的列名?快速浏览一下,在使用 Filter Col Selector 时必须注意两件事:
- 似乎 Filter Col Selector 总是使用 Current Data table() 并且您不能直接引用您要使用的数据表。 基于脚本索引,它应该接受 Datatable(name) 作为参数,所以很可能是一个错误(至少在 JMP16.1 中)。
- Filter Col Box 的红色三角形是一个不同的 DisplayBox,必须删除。
要解决参考问题,您可以尝试根据用户选择更改 Current Data Table() 并删除红色三角形,您可以将 Filter Col Box 包裹在 V List Box 周围并删除它。
Names Default To Here(1);
//get a list of window names
windows = Get Data Table List();
/*remove ones that are not data tables--need to start at back of list, because its length will change as we delete items
For( i = N Items( windows ), i > 0, i--,
If( (Window( windows[i] ) << Window Class Name) != "DataTable",
Remove From( windows, i )
)
);
*/
//make a dialog window
nw = New Window("Sample",
vlb1 = V List Box(
lb1 = List Box(
windows, //populate the listbox with data table names
//here is the script that runs each time someone clicks in the top box
//delete the current column list box, if it exists
Try(vlb2 << delete);
//append a new v list box which includes filter col selector
Current Data Table(Data Table((lb1 << get selected)[1]));
vlb1 << append(vlb2 = V List Box(Filter Col Selector()));
)
)
);这里还有一个简单的脚本来复制过滤器颜色选择器的问题:
Names Default To Here(1);
//Open two data tables
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Open("$SAMPLE_DATA/Consumer Preferences.jmp");
//Make sure the one not used in filter col selector is current data table
Current Data Table(dt2);
wait(0);
//Create filter col selector with non current data table
New Window("Filter Col Selector Example",
fontobj = lb = Filter Col Selector(Data table("Big Class"))
);Re: 如何动态列出所选数据表的列名?Names Default To Here(1);
//Open two data tables
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Open("$SAMPLE_DATA/Consumer Preferences.jmp");
//Make sure the one not used in filter col selector is current data table
Current Data Table(dt2);
wait(0);
//Create filter col selector with non current data table
New Window("Filter Col Selector Example",
fontobj = lb = Filter Col Selector(Data table(dt)) //replace "big class" with dt work.
);用数据表(dt)替换数据表(“大类”),它工作。