2014-05-20 57 views
0

我發佈在Infragistics論壇上無濟於事,所以我想我會問可能會使用他們產品的社區。Infragistics分層網格:將JsonResult綁定到網格

我正在用IgniteUI實現一個Hierarchical Grid,並且似乎無法讓我的JsonResult綁定到網格。網格將使用正確的行數進行呈現,但沒有填充任何列。

我有以下電網:

$("#grid").igHierarchicalGrid({ 
       dataSourceType: "json", 
       dataSource: "/Products/GetProducts/", 
       odata: "false", 
       autoGenerateColumns: "false", 
       primaryKey: "Id", 
       initialDataBindDepth: 1, 
       columns: [ 
        { headerText: "Id", key: "Id", dataType: "number" }, 
        { headerText: "SKU", key: "SKU", dataType: "string" }, 
        { headerText: "UPC", key: "UPC", dataType: "string" }, 
        { headerText: "Name", key: "Name", dataType: "string" }, 
        { headerText: "ManufacturerId", key: "ManufacturerId", dataType: "number" }, 
        { headerText: "ManufacturerSKU", key: "ManufacturerSKU", dataType: "string" }, 
        { headerText: "Inventory", key: "Inventory", dataType: "number" }, 
        { headerText: "Weight", key: "Weight", dataType: "number" }, 
        { headerText: "Price", key: "Price", dataType: "number" }, 
        { headerText: "MSRP", key: "MSRP", dataType: "number" }, 
        { headerText: "CategoryId", key: "CategoryId", dataType: "number" }, 
        { headerText: "Active", key: "Active", dataType: "string" }, 
        { headerText: "CreateDate", key: "CreateDate", dataType: "date", format: "MM-d-yyyy, h:mm tt" }, 
        { headerText: "UpdateDate", key: "UpdateDate", dataType: "date", format: "MM-d-yyyy, h:mm tt" } 
       ], 
       features: [ 
        { 
         name: "Sorting", 
         type: "local" 
        }, 
        { 
         filterExprUrlKey: 'filter', 
         filterLogicUrlKey: 'filterLogic', 
         name: "Filtering", 
         type: "remote", 
         columnSettings: [ 
        { 
         columnKey: 'Id', 
         condition: "equals" 
        } 
         ] 
        }, 
        { 
         name: 'Paging', 
         type: "local", 
         pageSize: 10 
        } 
       ], 
       columnLayouts: [ 
        { 
         key: "VendorProducts", 
         primaryKey: "Id", 
         foreignKey: "Id", 
         autoGenerateColumns: "false", 
         responseDataKey: 'results', 
         columns: [ 
          { headerText: "Id", key: "Id", dataType: "number" }, 
          { headerText: "ProductId", key: "ProductId", dataType: "number" }, 
          { headerText: "PartnerName", key: "PartnerName", dataType: "string" }, 
          { headerText: "VendorSKU", key: "VendorSKU", dataType: "string" }, 
          { headerText: "Cost", key: "Cost", dataType: "number" }, 
          { headerText: "Inventory", key: "Inventory", dataType: "number" }, 
          { headerText: "Active", key: "Active", dataType: "number" } 
         ], 
         features: [ 
          { 
           name: "Sorting", 
           type: "local" 
          }] 
        } 
       ] 
      }); 

將JSON從服務器返回如下

var data = [{ "Id": 1032, "SKU": "5_113990", "UPC": "10000001", "Name": "NVG7-3P", "ManufacturerId": 1015, "ManufacturerSKU": "NVGONVG73P", "Inventory": 0, "Weight": 3, "Price": 3026.6, "MSRP": 3799, "CategoryId": 1018, "Active": true, "CreateDate": "\/Date(1398794923467)\/", "UpdateDate": "\/Date(1400000587250)\/", "VendorProducts": [{ "Id": 1046, "ProductId": 1032, "PartnerName": "Direct Buy", "VendorSKU": "113990", "Cost": 0, "Inventory": 0, "Active": true }] }]; 

,當插入dataSource將使電網就好,電網來電然而,當出來的方法:

[HttpGet] 
     public JsonResult GetProducts() 
     {    
      var model = Query..... 
      return Json(model, JsonRequestBehavior.AllowGet); 
     } 

引發以下錯誤:

**Uncaught Error: There was an error parsing the JSON data and applying the defined data schema: The input data doesn't match the schema, the following field couldn't be mapped: VendorProducts** 

我已經嘗試了一些東西,但似乎無法獲得網格按需加載。

回答