Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Filter out an item from a dropdowndatawindow

Posted on 2001-07-26
7
Medium Priority
?
396 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 600 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

876 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