Come elencare dinamicamente i nomi delle colonne della tabella dati selezionata?Ciao,
Sto provando a creare una finestra come Tables-Join, in cui la seconda casella di contorno potrebbe elencare dinamicamente i nomi delle colonne della tabella di dati selezionata nella casella di riepilogo nell'angolo in alto a sinistra.
Grazie in anticipo.
ScriptingfinestreRi: Come elencare dinamicamente i nomi delle colonne della tabella dati selezionata?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.
);Sostituisci la tabella dei dati ("grande classe") con la tabella dei dati (dt), funziona.
Ri: Come elencare dinamicamente i nomi delle colonne della tabella dati selezionata?Osservando rapidamente questo, ci sono due cose che devono essere curate quando si utilizza Filter Col Selector:
- Sembra che Filter Col Selector utilizzi sempre la tabella dei dati correnti () e non puoi dargli un riferimento diretto al datatable che desideri utilizzare. Sulla base dell'indice di scripting dovrebbe accettare Datatable(name) come argomento, quindi molto probabilmente un bug (almeno in JMP16.1).
- Il triangolo rosso di Filter Col Box è un altro DisplayBox che deve essere eliminato.
Per aggirare la cosa di riferimento potresti provare a cambiare la Current Data Table () in base alla selezione dell'utente e per eliminare anche il triangolo rosso, puoi avvolgere Filter Col Box attorno a V List Box ed eliminarlo.
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()));
)
)
);Anche qui c'è un semplice script per replicare il problema con 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"))
);Ri: Come elencare dinamicamente i nomi delle colonne della tabella dati selezionata?Grazie per la risposta. Sostituisco 'col list box' con 'filter col selector', non funziona come previsto, viene lasciato un triangolo rosso ogni volta che seleziono una tabella, l'elenco delle colonne non si aggiorna di conseguenza.
come funziona utilizzando 'filter col selector'?
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 ) );
)
)
);

Ri: Come elencare dinamicamente i nomi delle colonne della tabella dati selezionata?Ciao,
È possibile utilizzare codice come il seguente per eseguire questa operazione. Prova a eseguire questo codice quando hai alcune tabelle di dati aperte.
Saluti,
Brady
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 ) );
)
)
);

