Solved

Datawindow Search capability

Posted on 2004-04-12
9
1,020 Views
Last Modified: 2013-12-26
Hi,

I need to have general search utility for my powerbuilder window. If i click on search button then, it should take all the current datawindow columns and perform a record search based on the selection criteria.

For Ex :
I have item_id,item_desc,item_qty
I need to get all these three fields in dropdown in my search window and i should be able to give inputs like item_id>10 and item_desc like 'VIDEO%'. Then if i click OK, i should get records based on that inputs. Tomorrow if i add one more column then, that also should populate in the dropdown in search window. I am not using PFCs in my app.

Thanks in advance
Srinib
0
Comment
Question by:srinib
[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
9 Comments
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10809062
Hi Srini,

You can use SetFilter.

Example:
datawindowchild ldw_child

dw_1.GetChild('item_id', ldw_child)
dw_inv.SetFilter("#1>"+ String( 10) &
            + " and #2>" + String(30))
ldw_child.Filter()


You can refer columns by number (#N) You do not need to hard-code. Also can obtain column count using describe.

<DW Control Name>.Describe("DataWindow.Column.Count")

Regards-



0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 10811173
hi,

1) get the list of columns:
long ll_count
string  ls_colname,ls_syntax
for ll_count = 1 to long(dw_1.Object.datawindow.column.count)
   ls_syntax = "#"+string(ll_count) + ".dbname"
   ls_colname = dw_1.describe(ls_syntax)

   // logic to add this column to drop down list box or dddw.
next

here, remember that dbname returns the column name with tablename i.e. tablename.columnname. so if table name is not really required then u can remove table name using mid, pos and right function.

2) now u can build the query for filter on button clicked from
column_name + operator + value + 'AND/OR'

ls_filter = column_name + operator + value + 'AND/OR'

dw_output.SetRedraw(FALSE)
dw_output.SetFilter(ls_filter)
dw_output.Filter()
dw_output.GroupCalc()
dw_output.SetRedraw(TRUE)

-sandeep
   
0
 
LVL 18

Expert Comment

by:diasroshan
ID: 10813360
hi,
create a dw say... dw_search(external) with the following columns colname, operator, value and join...
operator and join will be dropdown list boxes with values as (=,<,>,<>,like...) and (And,Or) respectively...

ur window has a search button and this dw(dw_search) and the datawindow on which u want to apply this search(dw_1)....

in the search button write the following code....
Long ll_Count,i
String ls_colname

dw_search.visible = True

ll_Count = Integer(dw_1.Describe('Datawindow.Column.Count'))

For i = 1 To ll_Count
      dw_search.InsertRow(i)
      ls_ColName = dw_1.Describe('#' + Trim(String(i)) + '.Name')
      dw_search.Object.colname[i] = ls_colname      
Next      


..add a button to ur dw_search with the caption search....
...in the buttonclicked event of dw_search write...
Long ll_Count,i
String ls_colname, ls_value ,ls_join, ls_operator, ls_filter, ls_filterfinal

dw_search.visible = True



For i = 1 to dw_search.RowCount()
      ls_colname = dw_search.Object.colname[i]
      If Isnull(ls_colname) or Len(Trim(ls_colname)) = 0 Then ls_colname = '%'
      ls_operator = dw_search.Object.operator[i]
      If Isnull(ls_operator) or Len(Trim(ls_operator)) = 0 Then ls_operator = '%'
      ls_value = dw_search.Object.value[i]
      If Isnull(ls_value) or Len(Trim(ls_value)) = 0 Then ls_value = '%'            
      ls_join = dw_search.Object.join[i]
      If Isnull(ls_join) or Len(Trim(ls_join)) = 0 Then ls_join = '%'      
      if ls_value = '%' Then
            dw_search.DeleteRow(i)
            Continue
      End If      
      If i = dw_search.RowCount() Then
                  ls_filter = ls_colname + " " + ls_operator + " '" + ls_value
      Else            
                  ls_filter = ls_colname + " " + ls_operator + " '" + ls_value + "' " + ls_join + " "
      End If            
      
      ls_filterfinal = ls_filterfinal + ls_filter
Next      

ls_filterfinal = Mid(ls_filterfinal,1,len(ls_filterfinal) -1)
dw_1.SetFilter(ls_filterfinal)
dw_1.Filter()


...u can use filter or find according to ur requirement....

...u might have to streamline the code a bit more to make consistent....
...any further clarification ...do ask...

Cheers,
Rosh
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 5

Expert Comment

by:gafoor78
ID: 10821018
Hi srinib

i hav a user object with me.. that is a single line edit, u can put just above ur datawindow and u can search any of the column in the dw.. u just need to register the columns u want to search in the constructor event of the uo.. u can serach string, date and numbers.. u can search multiple occurance by just hitting the enter.. in this case u only need to put the sle uo. no need of listbox and ok button

if u need to test it just send me a request in my mail.. i can send u it..

gafoor78@yahoo.com

regards
gafoor
0
 
LVL 1

Author Comment

by:srinib
ID: 10842176
Hi gafoor,

I am waiting for your user object. Please check your yahoo mail..

Thanks
Srinib
0
 
LVL 5

Expert Comment

by:gafoor78
ID: 10852609
Hi srinivas

i send it in ur mail...pls check and let me know.

rgrds
gafoor
0
 
LVL 1

Author Comment

by:srinib
ID: 10860774
Hi Gafoor,

I am not getting attachment as all the zip files are blocked at firewall. Please send directly the PBL without zipping it.

Thanks
Srini
0
 
LVL 5

Accepted Solution

by:
gafoor78 earned 100 total points
ID: 10868873
i send u the exported uo.. pls check ur mail..

rgrds
gafoor
0
 
LVL 1

Author Comment

by:srinib
ID: 10871992
Dear Gafoor,

My requirement is somthing else, i need record search and not text search. Anyhow your userobject helps me in another screens for text search.

Thanks again
Srinib
0

Featured Post

Industry Leaders: 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!

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 connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

729 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