2016-10-29 2 views
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); 
 
})();

답변

0

는 "DXSK8"솔루션에서 "DXSK8.Service"프로젝트가있다. 앱 데이터는 여기에 저장됩니다 : App_Data/SampleData.xml

브라우저에서 데이터를 가져 오려면 앱에서 "DXSK8.Shared"프로젝트 파일 data/db.js을 사용합니다. "DXSK8.Service"OData 서비스와 통신하는 ODataContext 개체가 있습니다. 구성 설정은 여기에 있습니다. DXSK8.Shared/shared.config.js