Solved

Filter out an item from a dropdowndatawindow

Posted on 2001-07-26
7
369 Views
Last Modified: 2013-12-26
I have a dropdowndatawindow that is used within other datawindows.  It is a list of all countries.  How do I filter out "United States of America" if I want to list only foreign countries in the dropdowndatawindow to display?
0
Comment
Question by:aorita
7 Comments
 
LVL 4

Accepted Solution

by:
Bhatti earned 200 total points
ID: 6324468
In your DDDW (DropDownDataWindow) select the retrieval argument from menu in datawindow painter SQL and give the retrieval argument , retrieve the countries where country <> 'United States of America'  or the number if you have a number for United States of America.
 (In WHERE retrieval argument column <> United States of America) //Hard codding

You can also put a vriable but always enter the variable in the dddw retrieve( United States of America) as retrieval parameter to avoid from retrieval argument dialogbox.

string                        ls_fcountry
datawindowchild    ldwc_child


dw_1.GetChild("columnname", ldwc_child)
ldwc_child.SetTransObject(sqlca)
ls_fcountry = "United States of America"
ldwc_child.retrieve(ls_fcountry)

//You declared in the datawindow painter SQL retrieval argument as string and in WHERE clause you wrote
//column <> :variable

If not help will write you other function.
0
 
LVL 4

Expert Comment

by:Bhatti
ID: 6325886
It is also good to practice the SetFilter() and Filter() function to use the filter your required data.

string                        ls_fcountry, ls_filter
datawindowchild    ldwc_child


dw_1.GetChild("columnname", ldwc_child)
ldwc_child.SetTransObject(sqlca)
ls_fcountry = "United States of America"
ls_filter = "columnname<> ' " + ls_fcountry + "'"

ldwc_child.SetFilter(ls_filter")
ldwc_child.Filter()


0
 
LVL 4

Expert Comment

by:Bhatti
ID: 6325899
Sorry I forgot, First use the Retrieve() function ldwc_child.retrieve(), without parameter and then use the Setfilter() and filter() functions.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:Bhatti
ID: 6344116
If this did not help you what I wrote above, we have another way also.

datawindowchild ldwc_child
datastore lds_ds //datastore for the list of countries
string ls_fcountry

lds_ds = create datastore
lds_ds.dataobject = 'd_datawindow_name'                        //name of the datawindow for you datastore
lds_ds.SetTransObject(SQLCA)
lds_ds.Retrieve()                                   //retrieve you all countries

ls_fcountry = "United States of America"
lds_ds.SetFilter(ls_fcountry)
lds_ds.Filter() //filter you your country

dw_1.GetChild("columnname", ldwc_child)
ldwc_child.SetTransObject(SQLCA)

ldwc_child.ReSet() //better for next call
lds_ds.RowsMove(1, lds_ds.RowCount(), Primary!, ldwc_child, 1, Primary!)

I do not know where you are writing you code. But in this way you will get always filtered data in
datawindowchild.

0
 
LVL 1

Expert Comment

by:levr
ID: 6346790

If the DataWindow is used in other places as well,
I think it is better not to alter DataWindow, but just delete unwanted data.

datawindowchild    ldchld
long ll_row

dw_1.GetChild("columnname", ldchld)
ldchld.Retrieve()
ll_row = ldchld.Find("country_name = 'United States of America'",1, ldchld.RowCount())
if ii_row > 0 then ldchld.DeleteRow(ll_row)

The code could be put in the window's open event.
Thanks, Lev
0
 

Expert Comment

by:darrelljude
ID: 6382419
I think to have a little flexibility, by adding a
messagebox before the filter.

On the datawindow control where the dd datawindow is
located in the "itemfocuschanged" event put this code

string lx_str
datawindowchild lx_dwchild
long lx_choice


choose case getcolumnname()
     case 'country_from'
          getchild('country_from',lx_dwchild)
          lx_choice = messagebox("Country List From Filter","Exclude United States?",Question!,YesNo!)
          if lx_choice = 1 then
             lx_dwchild.setfilter("trim(country) <> " + "'US'")
             lx_dwchild.filter()
         else

             lx_dwchild.setfilter("")
             lx_dwchild.filter()


          end if
         
      case 'country_to'
          getchild('country_to',lx_dwchild)
          lx_choice = messagebox("Country List To Filter","Exclude United States?",Question!,YesNo!)
          if lx_choice = 1 then
             lx_dwchild.setfilter("trim(country) <> " + "'US'")
             lx_dwchild.filter()
          else

             lx_dwchild.setfilter("")
             lx_dwchild.filter()


          end if
end choose
0
 

Expert Comment

by:kokan
ID: 6396031
aorita,

Please explain more on your question.  The answer seems too trivial.

kokan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now