- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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:
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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Filtering a List Box()
You can use the Filter Col Selector() with a bit of imagination
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 ) ) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Filtering a List Box()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Filtering a List Box()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 );