 |
Background
Nowadays, more and more web applications are build up with 3-tiers archetecture.
Business objects related to eachother exist in business tie. A common example is
the case of orders, order details and goods items. When it comes to presentation
tie, it is really a big headache to remain these objects as well as their relationships.
See the following chart.

Within Sigma Grid, rows data is consist of JSON object array instead of 2-dimension
array. This kind of archetecture allows developers to bind complex objects with
relationships to grid. With OGNL format supported, it is not a dream to convert
objects between presentation layer and logic ties smoothly.
Code
Step One
Declare colums as follows. Pay attention to name attributes.
var columns = [
{name:"goods.name",caption:"Model",width:80,mode:"string",readonly:true},
{name:"goods.spec",caption:"Spec",width:80,mode:"string",readonly:true},
{name:"goods.brand",caption:"Brand",width:80,mode:"string",readonly:true},
{name:"goods.unit.name",caption:"Measurement",width:80,mode:"string",readonly:true},
{name:"goods.stocks",caption:"In Stock",width:80,mode:"number",format:"#.0",readonly:true},
{name:"amount",caption:"Sold",width:100,mode:"number",format:"#.0"},
{name:"price",caption:"Price",width:100,mode:"number",format:"#.00"},
{name:"money",caption:"Total",width:120,mode:"number",format:"#.000",
formula:"p$('price')*p$('amount')"}
];
Step Two
Bind related objects to grid. Notice that order item objects contain goods items.
var order_items = [
{goods:{id:1,name:"Lap Top",brand:"ThinkPad",spec:"T43",stocks:100},amount:10,price:"16000"},
{goods:{id:2,name:"Lap Top",brand:"ThinkPad",spec:"X60",stocks:120},amount:5,price:"12000"},
{goods:{id:3,name:"Desk Top",brand:"Lenovo",spec:"E63",stocks:200},amount:5,price:"6500"},
{goods:{id:1,name:"Lap Top",brand:"ThinkPad",spec:"T43",stocks:100},amount:23,price:"16000"},
{goods:{id:2,name:"Lap Top",brand:"ThinkPad",spec:"X60",stocks:120},amount:56,price:"12000"},
{goods:{id:3,name:"Desk Top",brand:"Lenovo",spec:"E65",stocks:200},amount:7,price:"6500"}
];
Order & Goods
|
|
 |
|
|
All contents are (c) Copyright 2005 - 2007, Sigma Software
Inc. All rights Reserved |
|