CheckBoxTree綁定數據報錯:Cannot read property 'length' of undefined

我在測試的時候,發現checkBOXTree綁定數據的時候,提示錯誤以下:html

validating checkbox data: " TypeError: Cannot read property 'length' of undefined數據庫

以後發現是,數據的格式問題,不標準的數據格式每每會致使各類錯誤!json

數據必定按json格式問題,json格式中必須包含identifier和label,items。下圖是一組標準的數據格式,能夠按照這個格式綁定數據:數組

 

var liZi={
    identifier:'',
    label:'',
    items:[//我是數組,表示家庭成員
            {//媽媽
              name:"媽媽叫小紅",
              age:"小紅年齡30歲",
              children:[//媽媽的孩子
                {
                   name:"女兒叫小麗",
                   age:"年齡10歲"
                 }
              ]
            },
            {//姥姥
              name:"姥姥叫小美",
              age:"小美年齡60歲",
              children:[//姥姥的兒子
                {
                   name:"兒子叫小強",
                   age:"年齡40歲"
                 }
              ]
            }
    ]
}

 

諸如此類還有ItemFileWriteStore,注意items包含的數據是數組格式。服務器

下面是一個checkBOXTree和ItemFileWriteStore均可以用的簡單的數據例子:ide

{
    "identifier":"code",
    "label":"name",
    "items":[
        {
            "name":"數據庫服務器",
            "children":[
                {
                    "name":"orcl數據庫",
                    "checkbox":false,
                    "pid":"0",
                    "code":"141-3",
                    "type":"3"
                }
            ],
            "pid":"421",
            "code":"421-2",
            "type":"2"
        }
    ]
}

本人新手一個,文字表達能力通常,有錯誤但願各位指正測試

相關文章
相關標籤/搜索