Subscribe Bookmark RSS Feed

Use Combo box to select/deselect rows

bernie426

Community Trekker

Joined:

Feb 9, 2015

I like to set up a combo box that can help me to select/deselect/exclude/hide some rows in some specific row,

Can any help out on my script below?

Many Thanks,

Names Default To Here(1);

dt=Current Data table();

MRB_List={"Bin1", "Bin2", "Bin3", "Bin4", "Bin5"};

Prod_List={"Binned"};

New Window("Production & MRB Filter",Outline Box("Production Selection/Exclusion"),

  cb=Combo Box ({"MRB","Prodction Goods"},

  selection = cb << getselected()

  << select  where( Contains( MRB_List, :BinClass_ )),//<< Enable <<Exclude <<Hide

  << select  where( Contains( Prod_List, :Category ))),//<< Enable <<Exclude <<Hide

)

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Not sure I completely understand what you want. But this example should help with the 'mechanics' of the 'ComboBox()':

Names Default To Here(1);

// Make a table

n = 30;

MRB_List={"Bin1", "Bin2", "Bin3", "Bin4", "Bin5", , "Bin6", , "Bin7", , "Bin8", , "Bin9", , "Bin10"};

MRBVals = {};

for(i=1, i<=n, i++, InsertInto(MRBVals, MRB_List[RandomInteger(1, NItems(MRB_List))]));

dt = NewTable("Bin Data", NewColumn("BinClass_", Character, Nominal, Values(MRBVals)));

// Make the UI

New Window("MRB Filter",Outline Box("Bin Selection/Exclusion"), cb = Combo Box (MRB_List, cbScript));

cbScript =

Expr(

   myBin = cb << getselected;

   dt << clearRowStates;

   dt << selectWhere(:BinClass_ == myBin ) << Enable <<Exclude <<Hide;

);


3 REPLIES
Solution

Not sure I completely understand what you want. But this example should help with the 'mechanics' of the 'ComboBox()':

Names Default To Here(1);

// Make a table

n = 30;

MRB_List={"Bin1", "Bin2", "Bin3", "Bin4", "Bin5", , "Bin6", , "Bin7", , "Bin8", , "Bin9", , "Bin10"};

MRBVals = {};

for(i=1, i<=n, i++, InsertInto(MRBVals, MRB_List[RandomInteger(1, NItems(MRB_List))]));

dt = NewTable("Bin Data", NewColumn("BinClass_", Character, Nominal, Values(MRBVals)));

// Make the UI

New Window("MRB Filter",Outline Box("Bin Selection/Exclusion"), cb = Combo Box (MRB_List, cbScript));

cbScript =

Expr(

   myBin = cb << getselected;

   dt << clearRowStates;

   dt << selectWhere(:BinClass_ == myBin ) << Enable <<Exclude <<Hide;

);


bernie426

Community Trekker

Joined:

Feb 9, 2015

Thanks Ian,

You are very close to what I want. However, one step further on my question

If the column I like to select and exclude contains information {Bin1, Bin2....Bin10, Run#1, Run#2....Run#100 Recheck} and I like to select and exclude as rows that are related to Bin, Run#, and Recheck. Then, the script below does not work out, seems like the "% " cannot work this way.

Is there any alternative way?

Regards,

Names Default To Here(1);

dt=curent data table();

MRB_List={"Bin%", "Run%", "Recheck%"};

New Window("MRB Filter",Outline Box("Bin Selection/Exclusion"), cb = Combo Box (MRB_List, cbScript));

cbScript =

Expr(

   myBin = cb << getselected;

   dt << clearRowStates;

   dt << selectWhere(:BinClass_ == myBin ) << Enable <<Exclude <<Hide;

ian_jmp

Staff

Joined:

Jun 23, 2011

So, if I have understood correctly, you need to select multiple levels from the same column. 'ComboBox()' forces you to make one selection, but you can try 'ListBox()' instead (use the SHIFT or CONTROL keys as you click the items in the list):

Names Default To Here( 1 );

// Make a table

n = 30;

MRB_List = {"Bin1", "Bin2", "Bin3", "Bin4", "Bin5", , "Bin6", , "Bin7", , "Bin8", , "Bin9", , "Bin10"};

MRBVals = {};

For( i = 1, i <= n, i++,

Insert Into( MRBVals, MRB_List[Random Integer( 1, N Items( MRB_List ) )] )

);

dt = New Table( "Bin Data", New Column( "BinClass_", Character, Nominal, Values( MRBVals ) ) );

// Make the UI

New Window( "MRB Filter", Outline Box( "Bin Selection/Exclusion" ), lb = List Box( MRB_List, cbScript ) );

cbScript = Expr(

myBins = lb << getselected;

dt << clearRowStates;

dt << selectWhere( Contains(myBins, :BinClass_ )) << Enable << Exclude << Hide;

);