如何動態列出所選數據表的列名?你好呀,
我正在嘗試創建一個像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)替換數據表(“大類”),它工作。