cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
uwe_hiss
Level II

select all items in list box with button?

Hi,

does anyone know a solution to select all items in a listbox with a [All] button?


New Window( "Select ONE Monthly ", <<Modal,

V List Box(

      Text Box("ALL for Baseline"),

      mon = List Box(:Stage << get values),

      Button Box( "OK", cho = mon << get selected),

      )

);

dt_data << Select Where(Contains(cho, :Stage));


Regards and thank you in advance,

Uwe


1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: select all items in list box with button?

dt_data = Current Data Table();

mon_list = dt_data:Stage << get values;

New Window( "Select ONE Monthly ", << Modal,

     V List Box(

           Text Box( "ALL for Baseline" ),

           mon = List Box(mon_list),

           Button Box( "Select All",

                For( i = 1, i <= N Items( mon_list ), i++,

                     mon << set selected( i )

                )

           ),

           Button Box( "OK", cho = mon << get selected ),

     ),

);

dt_data << Select Where( Contains( cho, :Stage ) );

View solution in original post

6 REPLIES 6
pmroz
Super User

Re: select all items in list box with button?

dt_data = Current Data Table();

mon_list = dt_data:Stage << get values;

New Window( "Select ONE Monthly ", << Modal,

     V List Box(

           Text Box( "ALL for Baseline" ),

           mon = List Box(mon_list),

           Button Box( "Select All",

                For( i = 1, i <= N Items( mon_list ), i++,

                     mon << set selected( i )

                )

           ),

           Button Box( "OK", cho = mon << get selected ),

     ),

);

dt_data << Select Where( Contains( cho, :Stage ) );

uwe_hiss
Level II

Re: select all items in list box with button?

Thanks PMroz ... it works great :-)

pmroz
Super User

Re: select all items in list box with button?

There's a bug in my code if you have duplicates in the Stage column.  A side effect of putting a list into a listbox is that it will only display unique values.

This code will fix that:

Get_unique_values = Function( {in_list}, {Default Local},

    tmp = [=> 0];

    Insert Into( tmp, in_list );

    tmp << get keys;

);

dt_data = Current Data Table();

mon_list = get_unique_values( dt_data:Stage << get values );

New Window( "Select ONE Monthly ", <<Modal,

    V List Box(

        Text Box( "ALL for Baseline" ),

        mon = List Box( mon_list ),

        Button Box( "Select All",

            For( i = 1, i <= N Items( mon_list ), i++,

                mon << set selected( i )

            )

        ),

        Button Box( "OK", cho = mon << get selected ),

    ),

);

dt_data << Select Where( Contains( cho, :Stage ) );

uwe_hiss
Level II

Re: select all items in list box with button?

Hi Peter,

Thank you for fix it, but I didn't notice this problem or bug.

I have many duplicates in the column Stage, the Listbox displays only unique values.

How can I exclude a certain value like "Baseline"?

At best case, this should not appear in the listbox.


Regards

Uwe


Update:


mon_list = dt_data:Stage << get values;

for (j = N Items (mon_list), j > 0, j--,

if (mon_list == "Baseline",remove from (mon_list, j,1))

);

pmroz
Super User

Re: select all items in list box with button?

mon_list = get_unique_values( dt_data:Stage << get values );

bindex = contains(mon_list, "Baseline");

if (bindex > 0,

     remove from(mon_list, bindex);

);

uwe_hiss
Level II

Re: select all items in list box with button?

Hi Peter,

Thank you for the solutiuon.

Unfortunately it doesn't work for me, maybe it's up to v10


Regards,

Uwe