For a Web DB application, search filter is a mandatory feature. Search filter
comes in many flavors - Text, Date, Numeric, Boolean checkbox, Radio box, Select
DropDown Box Text contains, text starts with, hidden fields, Date field with
calendar assist, ReadOnly, Validation etc.. You'll find Tornado's search filter
implementation is the most powerful among it's class.
Simple Search
|
<!--T_Search_1.aspx-->
<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)
Dim Mydb As New Tornado.Z()
Mydb.dbQP = "U=2| M=ty=dh!sys=t| PS=11| S=plain| D=Nwind.Mdb|
Q=Orders| Gdf=0,1| Fmhf=0,1| TH=Title=Search Filter| navigationitem=b5,search|
filterflds=0,1"
Mydb.ASPdbNET()
End Sub
</script>
|
After defining a Dual display and the fields to display
in the grid and fields to hide in the form, add the
FilterFields and the Search navigation button parameters and
the entire Search Filter implementation is done. Execute the
live example and click the 'Search' button and you'll notice
that all the search setup is ready to go. Note that OrderID
is numeric and CustomerID is Text. Try the following actions
-
- Enter 10251 for OrderID and 'Go'
- Enter >10251 for OrderID and 'Go'
- Enter >=10251 and <=10256 for OrderID and
'Go'
- Enter >=10251 and <=10256 or >11000 for
OrderID and 'Go'
- Enter W for CustomerID and 'Go'
- Enter A or W and select
Starts With in the Text Comparison box for CustomerID and 'Go'
- With an active filter, leave all filter fields blank and hit 'Go' to
reset.
Now, you noticed that this Filter Search implementation is not really
'simple'. The 'simple' means simple to program. A quick question will be - How
about search for the Oregon state like State = AZ or State = OR or State = TX?
Go ahead and test that by just entering A or OR or B
in the CustomerID field and check out the Filter criteria in the status line to
see whether it is correct. What about the datetime field wrapper in MS-SQL as
they are different than Access? When you specify dbType, these differences will
be resolved internally. How about that? These are the questions that has been
asked by our customers for the pass 5 years and we honored majority of them. So,
what is the chance that you can re-use many of these customer driven features.
Advanced Search - Field Control
The following example is packed with advanced features. Just image how much
work it'll take you to product an application equivalent to this 17 lines of
code or you can do it al all.
|
<!--T_Search_2.aspx-->
<script runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
dim s as string = "in=EMPID,FULLNAME|sql=SELECT DISTINCTROW
Employees.EmployeeID, FirstName & ' ' & LastName AS FullName FROM Employees;"
s &= "ind=SHIPID,SHIPNAME|sql=SELECT DISTINCTROW
ShipperID,CompanyName FROM Shippers"
Dim Fadv1 As New Tornado.Z()
With Fadv1
.dbQP="U=109| D=Nwind.mdb| S=Air| M=ty=dh!sys=t|
Gdf=0,1| Fmhf=0,1| Ps=12| Q=Orders| Th=tit=Advanced Search| Fn=t| bof=filterdroptoggle=t|
ni=b5,filter"
.dbCalendar="Excludedates(0)=12/26/2001|12/27/2001|
Weeknumbers=true| buttonimage=/tornado/images-net/calendar_new1.gif"
.dbFilterFlds = "field=CustomerID|type=SelectBox+BN|value=CUID|text=CMPNAME|
note=Pick a Customer, field=EmployeeID|type=ROFilter| def=4| key=EMPID| lookup=FULLNAME|
note=Pick an Employee, field=OrderDate| type=TEXTCALENDAR| tag=SIZE=30| note=Select an
Order Date"
.dbCommonTables = s & "index=CUID,CMPNAME|sql=SELECT
DISTINCTROW CustomerID,CompanyName FROM Customers"
.dbLookUpFlds = "fie=1|key=CUID|loo=CMPNAME,fie=2|key=EMPID|loo=FULLNAME,field=6|keyindex=SHIPIDLookupindex=SHIPNAME"
.dbNameMap="fie=1|alias=Customer Name,
fie=2|alias=Employee Name"
.dbFilterSQL = "Select * From Orders where
[[Filter]]"
.ASPdbNET()
End With
End Sub
</script>
|
What is going on in this example?
- Common Tables are defined for field lookups to be used by display and
filter.
- Define datasource, Css, show/hide fields and suppress filter field
droptoggle button.
- Define popup Calendar properties.
- Define filter fields configuration. CustomerID is a DropBox, EmployeeID is
a Read Only field, use has no control of this field (Security). Lookup RO
field from lookup table, hookup OrderDate with a popup calendar.
- Furnish Notes along side of filter fields. Sometimes, a ton of validation
code is not better than a few words of explanation.
- Define a name alias (Caption) for fiedl #1 and #2.
- Define a user specified filter SQL The one listed in the code is the
default filter SQL. User can customize this SQL for ultimate control.