The datawindow is the work horse of PowerBuilder, when you have
been using it for a while it is easy to forget some of the basic but very powerful
built-in function of the Datawindow. Sort
You can specify the default sort sequence of the datawindow using a cool drag and drop
style response window, but you may not know that with two or three simple commands you can
offer the same dialog window to users of your application:
String ls_Null
SetNull( ls_Null )
dw_1.SetSort( ls_Null )
dw_1.Sort()
Filter
The filter is a great function for showing users slices of the data making the screen
less cluttered and making large amounts of data easier to deal with. Well the filter
dialog window is also available to your users:
String ls_Null
SetNull( ls_Null )
dw_1.SetFilter( ls_Null )
dw_1.Filter()
Query Mode
Query mode is a great feature for higher power users. It allows them to alter the where
clause by entering arguments into the Datawindow columns. For example whilst in query mode
the user could enter >500 to show all employees who's hourly rate was over
500 dollars. And if there are any companies out there who want to pay me 500 dollars an
hour send me an email :). Anyway enough fantasy, the user only extends the original where
clause so you can add a few basic joins and limits to the SQL to they don't bring the
server down. You can also query the Where clause so see what they altered it to and maybe
offer some ability to save their queries for future use. This code is based in the clicked
event of a checkbox to allow the user to toggle the query mode:
IF NOT this.checked THEN
dw_1.Modify("DataWindow.QueryMode=YES")
ELSE
dw_1.Modify("DataWindow.QueryMode=NO")
dw_1.Retrieve()
END IF
|