0
데모 샘플 "Skate Warehouse"(HTML5/JS DevExtreme)를 테스트하고 있습니다. 앱에서 Products.js의 데이터는 어디에서 가져 옵니까? 대신 텍스트 파일에서 정보를 읽고 제품에 표시 할 수 있습니까?"Skate Warehouse"(HTML5/JS DevExtreme)의 데이터 관리
Products.js :
window.DXSK8 = window.DXSK8 || {};
window.DXSK8.Store = window.DXSK8.Store || {};
window.DXSK8.Store.db = window.DXSK8.Store.db || {};
(function() {
var db = {},
TypeIds = {
deck: "74C9F584-429F-4F5B-8A9F-007D6176D6E4",
truck: "2D7D4288-E1D1-4116-AEEE-056EF87C011E",
wheels: "3182DE2E-417D-4B1F-9E6D-1CB073DC5A04"
}
db.loadProduct = function(id, success, fail) {
return DXSK8.db.Products.load({
select: [
"ID",
"Name",
"Price",
"Quantity",
"ImageUrl",
"Brand.Name"
],
filter: ["ID", new DevExpress.data.Guid(id)]
}).done(function (product) {
product = mapProduct(product[0]);
success.call(this, product);
}).fail(fail);
};
db.loadProducts = function(type, success, fail) {
DXSK8.db.Products.load({
select: [
"ID",
"Name",
"Price",
"Quantity",
"ImageUrl",
"Brand.Name"
],
filter: ["Type.ID", new DevExpress.data.Guid(TypeIds[type])]
}).done(function (products) {
products = $.map(products, mapProduct);
DevExpress.data.query(products)
.groupBy("brandName")
.enumerate()
.done(function (products) {
success.call(this, products);
})
}).fail(fail);
};
function mapProduct(product) {
var result = {
id: product.ID,
image: product.ImageUrl,
name: product.Name,
price: parseFloat(product.Price),
quantity: product.Quantity,
brandName: product.Brand.Name
}
return result;
}
$.extend(DXSK8.Store.db, db);
})();