如何動態列出選定資料表的列名?你好呀,
我正在嘗試建立一個類似Tables-Join 的窗口,其中第二個大綱框可以在左上角列錶框中動態列出所選資料表的列名稱。
先謝謝了。
資料混合與清理大規模客製化視窗回覆:如何動態列出選定資料表的列名?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.
);將資料表(“big class”)替換為資料表(dt),它可以工作。
回覆:如何動態列出選定資料表的列名?快速查看一下,使用 Filter Col Selector 時必須注意兩件事:
- 過濾器列選擇器似乎總是使用當前資料表(),而且您不能直接引用您要使用的資料表。 根據腳本索引,它應該接受 Datatable(name) 作為參數,因此很可能是錯誤(至少在 JMP16.1 中)。
- Filter Col Box 的紅色三角形是不同的 DisplayBox,必須刪除。
要解決參考問題,您可以嘗試根據使用者選擇更改當前資料表()並刪除紅色三角形,您可以將 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()));
)
)
);這裡還有一個簡單的腳本來複製 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"))
);回覆:如何動態列出選定資料表的列名?感謝你的回覆。 我將“列列錶框”替換為“過濾列選擇器”,它無法按預期工作,每次選擇表格時都會留下一個紅色三角形,列列表不會相應更新。
使用“過濾器選擇器”是如何運作的?
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 ) );
)
)
);

回覆:如何動態列出選定資料表的列名?你好,
您可以使用以下程式碼來執行此操作。 當您開啟幾個數據表時嘗試執行此程式碼。
乾杯,
布雷迪
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 ) );
)
)
);

