Solved

Filter out an item from a dropdowndatawindow

Posted on 2001-07-26
7
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
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: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

751 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