<%@ LANGUAGE="VBSCRIPT" %> <% Response.CacheControl = "no-cache" %> <% Response.AddHeader "Pragma", "no-cache" %> <% Response.Expires = -1 %> Rico LiveGrid-Example 4 (editable) <% '************************************************************************************************************ ' LiveGrid Plus-Edit Example '************************************************************************************************************ ' Matt Brown '************************************************************************************************************ dim orderTE, detailTE if OpenGridForm(empty,"customers") then set orderTE=OpenTableEdit("orders") set detailTE=OpenTableEdit("order_details") if oForm.action<>"table" then DefineCustTable elseif orderTE.action<>"table" then DefineOrderTable elseif detailTE.action<>"table" then DefineDetailTable else DisplayAllTables end if end if CloseApp sub DisplayAllTables() response.write "
" %> <% response.write "
Double-click on a row to see all orders for that customer." response.write "

Drag the edge of a column heading to resize a column." response.write "

To filter: right-click (ctrl-click in Opera, Konqueror, or Safari) on the value that you would like to use as the basis for filtering, then select the desired filtering method from the pop-up menu." response.write "

Right-click anywhere in a column to see sort, hide, and show options." response.write "

Notice that filters and sorting in the customer grid persist after a refresh. The saveColumnInfo option specifies that these values should be saved in cookies." response.write "

" DefineCustTable DefineOrderTable DefineDetailTable createInitScript response.write "
" 'response.write "

" end sub sub createInitScript() response.write vbLf & "" end sub sub DefineCustTable() oForm.options("RecordName")="Customer" oForm.options("visibleRows")="body" oForm.options("frozenColumns")=2 oForm.options("highlightElem")="menuRow" oForm.options("menuEvent")="contextmenu" oForm.AddEntryFieldW "CustomerID","Cust ID","B","",60 oForm.ConfirmDeleteColumn oForm.SortAsc oForm.AddEntryFieldW "CompanyName","Company Name","B","",220 oForm.AddEntryFieldW "ContactName","Contact","B","",120 oForm.AddEntryFieldW "Address","Address","B","",200 oForm.AddEntryFieldW "City","City","B","",110 oForm.AddEntryFieldW "Region","Region","N","",50 oForm.AddEntryFieldW "PostalCode","Postal Code","B","",80 oForm.AddEntryFieldW "Country","Country","N","",90 oForm.AddEntryFieldW "Phone","Phone","B","",110 oForm.AddEntryFieldW "Fax","Fax","B","",110 'oForm.AutoInit=false oForm.DisplayPage end sub sub DefineOrderTable() orderTE.options("RecordName")="Order" orderTE.options("frozenColumns")=2 orderTE.options("prefetchBuffer")=false orderTE.options("visibleRows")=4 orderTE.options("highlightElem")="menuRow" orderTE.options("menuEvent")="contextmenu" orderTE.AutoInit=false orderTE.AddEntryFieldW "CustomerID","Cust ID","B","",60 orderTE.CurrentField("InsertOnly")=true ' do not allow customer to be changed once an order is entered orderTE.AddPanel "Basic Info" orderTE.AddEntryFieldW "OrderID","Order ID","B","",60 orderTE.ConfirmDeleteColumn orderTE.SortAsc orderTE.AddEntryFieldW "EmployeeID","Sales Person","SL","",140 orderTE.CurrentField("SelectSql")="select EmployeeID," & oDB.concat(Array("LastName","', '","FirstName"),false) & " from Employees order by LastName,FirstName" orderTE.AddEntryFieldW "OrderDate","Order Date","D",Date(),90 orderTE.CurrentField("SelectCtl")="Cal" orderTE.AddEntryFieldW "RequiredDate","Required Date","D",Date(),90 orderTE.CurrentField("SelectCtl")="Cal" orderTE.AddCalculatedField "select sum(UnitPrice*Quantity*(1.0-Discount)) from order_details d where d.OrderID=t.OrderID","Net Sale" orderTE.CurrentField("format")="DOLLAR" orderTE.CurrentField("width")=80 orderTE.AddPanel "Ship To" orderTE.AddEntryFieldW "ShipName","Name","B","",140 orderTE.AddEntryFieldW "ShipAddress","Address","B","",140 orderTE.AddEntryFieldW "ShipCity","City","B","",120 orderTE.AddEntryFieldW "ShipRegion","Region","T","",60 orderTE.AddEntryFieldW "ShipPostalCode","Postal Code","T","",100 orderTE.AddEntryFieldW "ShipCountry","Country","N","",100 orderTE.DisplayPage end sub sub DefineDetailTable() detailTE.options("RecordName")="Line Item" detailTE.options("frozenColumns")=2 detailTE.options("prefetchBuffer")=false detailTE.options("visibleRows")=4 detailTE.options("highlightElem")="menuRow" detailTE.options("menuEvent")="contextmenu" detailTE.AutoInit=false detailTE.AddEntryFieldW "OrderID","Order ID","I","",60 detailTE.AddEntryFieldW "ProductID","Product","SL","",140 detailTE.SortAsc detailTE.CurrentField("SelectSql")="select ProductID,ProductName from products order by ProductName" detailTE.AddEntryFieldW "UnitPrice","Unit Price","B","",80 detailTE.CurrentField("format")="DOLLAR" detailTE.AddEntryFieldW "Quantity","Quantity","I","",80 detailTE.CurrentField("format")="QTY" detailTE.AddEntryFieldW "Discount","Discount","B","",80 detailTE.CurrentField("format")="PERCENT" detailTE.DisplayPage end sub %>