Solved

Filter out an item from a dropdowndatawindow

Posted on 2001-07-26
7
372 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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ā€¦
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

777 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