Hello there,
I'm tring to creat a windows like Tables-Join, which the second outline box could dynamically list the column names of selected data table in the upleft corner list box.
Thanks in advanced.
Hello,
You can use code like the following to do this. Try running this code when you have a few data tables open.
Cheers,
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 ) ); ) ) );
Thank you for your reply. I replace 'col list box' with 'filter col selector', it doesn't work as expected, a red triangle left every time I select a table, the column list doesn't update accordingly.
how does it work through by using '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 ) ); ) ) );
Quickly looking at this there are two things that must be taken care of when using Filter Col Selector:
To work around the reference thing you could try changing the Current Data Table() based on the user selection and to delete also the red triangle, you can wrap Filter Col Box around V List Box and delete that.
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())); ) ) );
Also here is simple script to replicate the issue with 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); //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. );
Replace data table("big class") with data table (dt),it work.