Solved

Datawindow Search capability

Posted on 2004-04-12
9
1,014 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
9 Comments
 
LVL 15

Expert Comment

by:namasi_navaretnam
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 5

Expert Comment

by:gafoor78
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 1

Author Comment

by:srinib
Comment Utility
Hi gafoor,

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

Thanks
Srinib
0
 
LVL 5

Expert Comment

by:gafoor78
Comment Utility
Hi srinivas

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

rgrds
gafoor
0
 
LVL 1

Author Comment

by:srinib
Comment Utility
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
Comment Utility
i send u the exported uo.. pls check ur mail..

rgrds
gafoor
0
 
LVL 1

Author Comment

by:srinib
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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…

762 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

13 Experts available now in Live!

Get 1:1 Help Now