Include the client JavaScript & CSS libraries
<link rel="stylesheet" type="text/css" href="dbnetsuite.css.ashx" />
<script language="JavaScript" src="dbnetsuite.js.ashx"></script>
Client-side configuration script
<script>
jQuery(document).ready( init )
function init()
{
var orderDetailsForm = new DbNetEdit("orderDetailsForm");
with (orderDetailsForm)
{
connectionString = "SamplesDatabase"
fromPart = "[order details]"
setColumnExpressions("OrderID","ProductID","UnitPrice","Quantity","Discount")
setColumnProperty("OrderID","primaryKey", true)
setColumnProperty("OrderID","foreignKey", true)
setColumnProperty("ProductID","primaryKey", true)
setColumnProperty("ProductID","Lookup", "select productid, productname from products")
}
var ordersForm = new DbNetEdit("ordersForm");
with (ordersForm)
{
connectionString = "SamplesDatabase"
fromPart = "orders"
setColumnExpressions("CustomerID","OrderID","OrderDate","RequiredDate","ShippedDate","Freight")
setColumnProperty("CustomerID","foreignKey",true)
setColumnProperty("OrderID","primaryKey",true)
}
var customersForm = new DbNetEdit("customersForm");
with (customersForm)
{
connectionString = "SamplesDatabase"
fromPart = "customers"
setColumnExpressions("CustomerID","CompanyName","Address","City")
setColumnProperty("CustomerID","primaryKey",true)
}
var orderDetailsGrid = new DbNetGrid("orderDetailsGrid");
with (orderDetailsGrid)
{
connectionString = "SamplesDatabase"
fromPart = "[order details]"
pageSize = 5
setColumnExpressions("OrderID","ProductID","UnitPrice","Quantity","Discount")
setColumnProperty("ProductID","lookup","select productid, productname from products")
setColumnProperty("Discount","format","p")
setColumnProperty("OrderID","foreignKey",true)
addLinkedControl(orderDetailsForm,true)
}
var ordersGrid = new DbNetGrid("ordersGrid");
with (ordersGrid)
{
connectionString = "SamplesDatabase"
fromPart = "orders"
pageSize = 5
setColumnExpressions("CustomerID","OrderID","OrderDate","RequiredDate")
setColumnProperty("CustomerID","ForeignKey", true)
addLinkedControl(orderDetailsGrid,false)
addLinkedControl(ordersForm,true)
}
var customersGrid = new DbNetGrid("customersGrid");
with (customersGrid)
{
connectionString = "SamplesDatabase"
fromPart = "customers"
pageSize = 5
setColumnExpressions("companyname","city");
addLinkedControl(ordersGrid,false)
addLinkedControl(customersForm,true)
initialize()
}
}
</script>
HTML markup
<h3>Customers</h3>
<hr />
<div id="customersGrid" style="float:left;margin-right:20px;"></div>
<div id="customersForm" style="float:left"></div>
<h3 style="clear:both">Orders</h3>
<hr />
<div id="ordersGrid" style="float:left;margin-right:20px;"></div>
<div id="ordersForm" style="float:left"></div>
<h3 style="clear:both">Order Details</h3>
<hr />
<div id="orderDetailsGrid" style="float:left;margin-right:20px;"></div>
<div id="orderDetailsForm" style="float:left"></div>