// 文字列配列列でビューを追加します。
productTable.addView("productView", [
"id", "name", "reorderLevel", "unitPrice", "unitsInStock", "unitsOnOrder"
]);
// カスタマイズされた列でビューを追加します。
productTable.addView("productView", [{
value: "id",
caption: "ID",
isPrimaryKey: true
}, {
value: "name",
caption: "NAME",
required: true
}, {
value: "quantityPerUnit",
caption: "QUANTITY PER UNIT"
}, {
value: "unitPrice",
caption: "UNIT PRICE"
}, {
value: "unitsInStock",
caption: "UNITS IN STOCK",
readonly: true
}, {
value: "unitsOnOrder",
caption: "UNITS ON ORDER"
}, {
value: "reorderLevel",
caption: "REORDER LEVEL"
}, {
value: "discontinued",
caption: "DISCONTINUED",
defaultValue: false
});
//リレーションシップ列を持つビューを追加します。
var supplierRelationship = dataManager.addRelationship(productTable, "supplierId", "supplier", supplierTable, "id", "products");
productTable.addView("productWithSupplierView", [{
value: "id",
caption: "ID"
}, {
value: "name",
caption: "NAME"
}, {
value: "supplier.companyName", // relationship
caption: "SUPPLIER NAME"
}, {
value: "supplier.contactName", // relationship
caption: "SUPPLIER CONTACT NAME"
}, {
value: "supplier.contactTitle", // relationship
caption: "SUPPLIER CONTACT TITLE"
});
// 計算フィールド列を持つビューを追加します。
var supplierRelationship = dataManager.addRelationship(productTable, "supplierId", "supplier", supplierTable, "id", "products");
productTable.addView("productWithSupplierView", [{
value: "id",
caption: "ID"
}, {
value: "name",
caption: "NAME"
}, {
caption: "TOTAL PRICE",
value: "=(unitsInStock + unitsOnOrder) * unitPrice"
}, {
caption: "SUPPLIER'S INFO",
value: "=CONCAT(supplierTable.companyName, ', ', supplierTable.contactName)"
});