Subscribe Bookmark RSS Feed

select all items in list box with button?

uwe_hiss

Community Trekker

Joined:

Aug 12, 2015

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
Solution

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 ) );

6 REPLIES
Solution

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

Community Trekker

Joined:

Aug 12, 2015

Thanks PMroz ... it works great :-)

pmroz

Super User

Joined:

Jun 23, 2011

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

Community Trekker

Joined:

Aug 12, 2015

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

Joined:

Jun 23, 2011

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

Community Trekker

Joined:

Aug 12, 2015

Hi Peter,

Thank you for the solutiuon.

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


Regards,

Uwe