cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
klk
klk
Level III

Filtering a List Box()

I'm looking for an easy way to filter a List Box() object. The simplest example I can come up with is this:

Names Default To Here( 1 );
win = New Window( "Test", lbox = List Box( {"orange", "red", "green", "blue"} ) );

Now I want to add a 'filter' box above the list of colors, similar to the filter you can get above a list of columns like this:

klk_0-1598381278624.png

I was hoping that there was some easy way to dump a filter on the dumb list but I'm not finding anything.

 

Thanks for any help!

1 ACCEPTED SOLUTION

Accepted Solutions
klk
klk
Level III

Re: Filtering a List Box()

I stumbled upon the right search terms and found this:

 

And was able to force the filter box on.  Here's what I ended up with:

Names Default To Here( 1 );
dset_names = {"orange", "red", "green", "blue"};

// make a temporary table with empty columns
dt_list = New Table( "tmp_list_table", private );
For( ci = 1, ci <= N Items( dset_names ), ci++,
	dt_list << New Column( dset_names[ci] )
);

colnames = {};
win = New Window( "Choose columns to import",
	<<Modal,
	<<Return Result,
	<<On Close( Close( dt_list, nosave ) ),
	H List Box(
		lb = Filter Col Selector( dt_list, width( 250 ), nlines( 10 ) ),
		// force the filter box to be displayed
		ib = (lb << Parent) << Xpath( "//IfBox" );
		ib << set( 1 );,
		Lineup Box( N Col( 1 ), Spacing( 2 ),
			Button Box( "Add Selected ->",
				dispcols << Append( lb << Get Selected );
				colnames = dispcols << Get Items;
			),
			Button Box( "<- Remove Selected",
				dispcols << Remove Selected;
				colnames = dispcols << Get Items;
			)
		),
		dispcols = List Box( {}, width( 250 ), nlines( 10 ) )
	)
);

// show what was chosen!
Show( colnames );

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Filtering a List Box()

You can use the Filter Col Selector() with a bit of imagination

coldiag.PNG

names default to here(1);
dtList = New Table("invisible",private,
	new column("Orange",character),
	new column("Red",character),
	new column("Green",character),
	new column("Blue",character),
);
New Window( "Col List Box Example", fontobj = lb = Filter Col Selector( width( 250 ) ) );

 

Jim
klk
klk
Level III

Re: Filtering a List Box()

Yeah, that was one of my other ideas if there wasn't some special argument to the List Box to just get it to show a filter. I'll try this out.
txnelson
Super User

Re: Filtering a List Box()

See my changed entry above.
Jim
klk
klk
Level III

Re: Filtering a List Box()

One final question - is there a message to force the filter to turn on? I tried like

Filter Col Selector( list, width(250), << Show Filter)

maybe a more general question is, how do I find a list of messages that an object allows?

klk
klk
Level III

Re: Filtering a List Box()

I stumbled upon the right search terms and found this:

 

And was able to force the filter box on.  Here's what I ended up with:

Names Default To Here( 1 );
dset_names = {"orange", "red", "green", "blue"};

// make a temporary table with empty columns
dt_list = New Table( "tmp_list_table", private );
For( ci = 1, ci <= N Items( dset_names ), ci++,
	dt_list << New Column( dset_names[ci] )
);

colnames = {};
win = New Window( "Choose columns to import",
	<<Modal,
	<<Return Result,
	<<On Close( Close( dt_list, nosave ) ),
	H List Box(
		lb = Filter Col Selector( dt_list, width( 250 ), nlines( 10 ) ),
		// force the filter box to be displayed
		ib = (lb << Parent) << Xpath( "//IfBox" );
		ib << set( 1 );,
		Lineup Box( N Col( 1 ), Spacing( 2 ),
			Button Box( "Add Selected ->",
				dispcols << Append( lb << Get Selected );
				colnames = dispcols << Get Items;
			),
			Button Box( "<- Remove Selected",
				dispcols << Remove Selected;
				colnames = dispcols << Get Items;
			)
		),
		dispcols = List Box( {}, width( 250 ), nlines( 10 ) )
	)
);

// show what was chosen!
Show( colnames );