2013-06-12 132 views
0

數據我有以下代碼沒有顯示在劍道UI電網

var entries = [ 
        { "value":"AAPL", "data":665.24, "shares":100 }, 
        { "value":"AMZN", "data":248.27, "shares":100 }, 
        { "value":"IBM", "data":194.85, "shares":100 }, 
        { "value":"CSCO", "data":19.08, "shares":100 }, 
        { "value":"MSFT", "data":30.82, "shares":100 }, 
        { "value":"INTC", "data":24.83, "shares":100 }, 
        { "value":"QCOM", "data":61.46, "shares":100 }, 
        { "value":"ORCL", "data":31.65, "shares":100 }, 
        { "value":"HPQ", "data":16.88, "shares":100 }, 
        { "value":"CRM", "data":145.18, "shares":100 } 
       ]; 
       var kendogridds = new kendo.data.DataSource({data:entries, 
        schema:{ 
         model:{ 
          fields:{ 
           value:{ type:"string" }, 
           data:{ type:"string" } 
          } 

         } 
        }}) 


       $('#myupdategrid').kendoGrid({ 
        dataSource:kendogridds, 
        height: 100, 
        columns:[{field:'data',title:'Data'}, 
        {field:'value',title:'Value'}], 
        dataBound: onDataBound, 
        dataBinding: onDataBinding 

       }) 

我可以看到正在創建的網格,但所有的細胞是空的。任何線索爲什麼?

+0

您曾經試圖填補'columns'所有字段?我的意思不僅是數據' – pbibergal

+0

不,我沒有。以前我只有兩列這樣的數據,但它也沒有工作。 – allthenutsandbolts

+0

根據此示例,您的架構模型存在問題:http://docs.kendoui.c​​om/api/web/grid – pbibergal

回答

0

你說得對。模型有些奇怪。我不認爲它喜歡數據作爲數據陣列中的關鍵。一旦我改變了這一切,一切都開始正常工作。我希望這可以幫助人們。

這是我的代碼

var typeObject = {} 
         typeObject.name = properties 
         typeObject.value = map[properties] 
         gridArray.push(typeObject) 

var kendogridds = new kendo.data.DataSource({ 
        data:gridArray, 
        schema:{ 
         model:{ 
          fields:{ 
           name:{ type:"string" }, 
           value:{ type:"string" } 
          } 

         } 
        }}) 


       console.log(kendogridds) 
       $('#myupdategrid').kendoGrid({autoBind:false, 
        dataSource:kendogridds, 
        columns: [{ 
         field: "name",// create a column bound to the "name" field 
         title: "Data" // set its title to "Name" 
        }, { 
         field: "value",// create a column bound to the "age" field 
         title: "Value" // set its title to "Age" 
        }] 

       }) 
       kendogridds.read()