Filter DCBOWSE of Array

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
jdsoft
Posts: 113
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

Filter DCBOWSE of Array

#1 Post by jdsoft »

Hello,

Maybe a silly question.
Is there a way to "Filter" lines in a DCBROWSE of array?
I would like to filter lines of type 1and type 2 controlled by the radiobutton.
So items of type 1 are only visible if type 1 is selected.
Items of type 2 are only visible if type 2 is selected.
The code below shows all types.

Suggestions are welcome.
Regards,
Jack Duijf

Code: Select all

#include "dcdialog.ch"
#pragma Library("dclipx.lib")

PROCEDURE MAIN

LOCAL GetList        := {}
LOCAL aData          := {}
LOCAL GetOptions     := {}
LOCAL oBrowse        := nil
LOCAL oBox           := oBox
LOCAL n              := 0
LOCAL nType          := 1

Aadd(aData,{1,"Item 1","Type 1",1})
Aadd(aData,{2,"Item 2","Type 2",2})
Aadd(aData,{3,"Item 3","Type 1",1})
Aadd(aData,{4,"Item 4","Type 2",2})
Aadd(aData,{5,"Item 5","Type 1",1})
Aadd(aData,{6,"Item 6","Type 2",2})
Aadd(aData,{7,"Item 7","Type 1",1})
Aadd(aData,{8,"Item 8","Type 2",2})
Aadd(aData,{9,"Item 9","Type 1",1})

@ 0,0    DCGROUP oBox SIZE 30,3 CAPTION "Show"
@ 1,1    DCRADIOBUTTON nType  PROMPT "Type 1" VALUE 1  PARENT oBox
@ 1,15   DCRADIOBUTTON nType  PROMPT "Type 2" VALUE 2  PARENT oBox
DCSETPARENT TO
@ 4,2    DCBROWSE oBrowse DATA aData SIZE 100,15  NOHSCROLL  ;
         PRESENTATION DC_BrowPres() ;
         ITEMSELECTED {||MsgBox(aData[n,2] + " selected.")} ;
         FIT POINTER n

DCBROWSECOL ELEMENT 1 HEADER "Id"    WIDTH  3 PARENT oBrowse
DCBROWSECOL ELEMENT 2 HEADER "Name"  WIDTH 15 PARENT oBrowse
DCBROWSECOL ELEMENT 3 HEADER "Type"  WIDTH 15 PARENT oBrowse

DCGETOPTIONS AUTORESIZE

DCREAD GUI FIT ADDBUTTONS MODAL ;
     OPTIONS GetOptions ;
     TITLE 'How to filter elements in a array?'
Return
Regards,
Jack Duijf

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Filter DCBOWSE of Array

#2 Post by rdonnay »

Jack -

Use the FILTER clause of @..DCBROWSE.

Like this:

Code: Select all

@ .. DCBROWSE ;
  FILTER {|a|a[4] == nType}
Roger
The eXpress train is coming - and it has more cars.

User avatar
jdsoft
Posts: 113
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

Re: Filter DCBOWSE of Array

#3 Post by jdsoft »

Hello Roger,

Thank yoy for the suggestion.
I wasn's aware of this function, and missed it in the docs. :oops:

Regards,
Jack Duijf
Regards,
Jack Duijf

Post Reply