6f74943252b4f728b6f336b054cc702b5b9a6a9a
[infodrom/rico3] / examples / asp / ex2editfilterKW.asp
1 <%@ LANGUAGE="VBSCRIPT" %>\r
2 <% Response.CacheControl = "no-cache" %>\r
3 <% Response.AddHeader "Pragma", "no-cache" %> \r
4 <% Response.Expires = -1 %>\r
5 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\r
6 <html>\r
7 <head>\r
8 <title>Rico LiveGrid-Example 2 (editable)</title>\r
9 \r
10 <!-- #INCLUDE FILE = "dbConnect.asp" --> \r
11 <!-- #INCLUDE FILE = "../../plugins/asp/ricoLiveGridForms.vbs" --> \r
12 <!-- #INCLUDE FILE = "../../plugins/asp/LoadRicoClient.asp" -->\r
13 <%\r
14 Dim RicoClient\r
15 set RicoClient = new LoadRicoClient\r
16 RicoClient.SetRicoClientParentPath "../../ricoClient/"\r
17 RicoClient.CheckQueryString   ' just for demo\r
18 RicoClient.CreateLinks\r
19 set RicoClient = Nothing\r
20 %>\r
21 \r
22 <link href="../demo.css" type="text/css" rel="stylesheet" />\r
23 \r
24 <script type='text/javascript'>\r
25 \r
26 // ricoLiveGridForms will call orders_FormInit right before grid & form initialization.\r
27 \r
28 function orders_FormInit() {\r
29   var cal=new Rico.CalendarControl("Cal");\r
30   Rico.EditControls.register(cal, Rico.imgDir+'calarrow.png');\r
31   \r
32   var kwSearch=new Rico.KeywordSearch("CustomerSearch");\r
33   Rico.EditControls.register(kwSearch, Rico.imgDir+'dotbutton.gif');\r
34 }\r
35 </script>\r
36 <style type="text/css">\r
37 div.ricoLG_outerDiv thead .ricoLG_cell, div.ricoLG_outerDiv thead td, div.ricoLG_outerDiv thead th {\r
38         height:1.5em;\r
39 }\r
40 div.ricoLG_cell {\r
41   white-space:nowrap;\r
42 }\r
43 </style>\r
44 </head>\r
45 \r
46 \r
47 <body>\r
48 \r
49 <%\r
50 '************************************************************************************************************\r
51 '  LiveGrid Plus-Edit Example\r
52 '************************************************************************************************************\r
53 '  Matt Brown\r
54 '************************************************************************************************************\r
55 \r
56 if OpenGridForm(empty,"Orders") then\r
57   if oForm.action="table" then DisplayHeading\r
58   DefineFields\r
59 end if\r
60 CloseApp\r
61 \r
62 \r
63 sub DisplayHeading()\r
64   response.write vbLf & "<div id='explanation'>"\r
65   response.write vbLf & "Base Library: <script type='text/javascript'>document.write(Rico.Lib+' '+Rico.LibVersion);</script>"\r
66   response.write vbLf & "<hr>The data on this grid can be edited using pop-up forms. "\r
67   response.write vbLf & "Just click on a grid cell and then select Edit, Delete, or Add from the pop-up menu. "\r
68   response.write vbLf & "The Add and Edit forms are automatically generated by LiveGrid. "\r
69   response.write vbLf & "Notice on the Add form how you use the Rico Tree control to select the customer. "\r
70   response.write vbLf & "Notice on the Edit form how the Rico Calendar is used to change dates. "\r
71   response.write vbLf & "Updates are disabled on the database, so you will get an error message if you try to save."\r
72   response.write vbLf & "</div>"\r
73   response.write vbLf & "<p><strong>Orders Table</strong></p>"\r
74 end sub\r
75 \r
76 \r
77 sub DefineFields()\r
78   dim colnum,LookupSQL\r
79   'oForm.options("showSaveMsg")="full"\r
80   'oForm.DebugFlag=true\r
81   oForm.options("FilterLocation")=-1\r
82   oForm.options("panelWidth")=500\r
83   oForm.options("frozenColumns")=1\r
84   oForm.options("menuEvent")="click"\r
85   oForm.options("highlightElem")="cursorRow"\r
86   \r
87   oForm.AddPanel "Basic Info"\r
88   oForm.AddEntryFieldW "OrderID","Order ID","B","<auto>",50\r
89   oForm.ConfirmDeleteColumn\r
90   oForm.SortAsc\r
91 \r
92   LookupSQL="select CustomerID,CompanyName from Customers order by CompanyName"\r
93   oForm.AddLookupField "CustomerID",empty,"CustID","Customer","CL","",LookupSQL\r
94   oForm.LookupField("SelectCtl")="CustomerSearch"\r
95   oForm.LookupField("InsertOnly")=true   ' do not allow customer to be changed once an order is entered\r
96   oForm.CurrentField("width")=160\r
97   oForm.CurrentField("filterUI")="t"\r
98 \r
99   LookupSQL="select EmployeeID," & oDB.concat(Array("LastName","', '","FirstName"),false) & " from Employees order by LastName,FirstName"\r
100   oForm.AddLookupField "EmployeeID",empty,"EmployeeID","Sales Person","SL","",LookupSQL\r
101   oForm.CurrentField("width")=140\r
102   oForm.CurrentField("filterUI")="m"\r
103 \r
104   oForm.AddEntryFieldW "OrderDate","Order Date","D",Date(),90\r
105   oForm.CurrentField("SelectCtl")="Cal"\r
106   oForm.AddEntryFieldW "RequiredDate","Required Date","D",Date(),90\r
107   oForm.CurrentField("SelectCtl")="Cal"\r
108   oForm.AddCalculatedField "select sum(UnitPrice*Quantity*(1.0-Discount)) from order_details d where d.OrderID=t.OrderID","Net Sale"\r
109   oForm.CurrentField("format")="DOLLAR"\r
110   oForm.CurrentField("width")=80\r
111 \r
112   oForm.AddPanel "Ship To"\r
113   oForm.AddEntryFieldW "ShipName","Name","B","",140\r
114   oForm.AddEntryFieldW "ShipAddress","Address","B","",140\r
115   oForm.AddEntryFieldW "ShipCity","City","B","",120\r
116   oForm.CurrentField("filterUI")="s"\r
117   oForm.AddEntryFieldW "ShipRegion","Region","T","",60\r
118   oForm.AddEntryFieldW "ShipPostalCode","Postal Code","T","",100\r
119   \r
120   ' display ShipCountry with a link to wikipedia\r
121   colnum=oForm.AddEntryFieldW("ShipCountry","Country","N","",100)\r
122   oForm.CurrentField("control")="new Rico.TableColumn.link('http://en.wikipedia.org/wiki/{" & colnum & "}','_blank')"\r
123   oForm.CurrentField("filterUI")="s"\r
124 \r
125   'oForm.AutoInit=false\r
126   oForm.DisplayPage\r
127 end sub\r
128 \r
129 %>\r
130 \r
131 </body>\r
132 </html>\r