2013-05-11 153 views
0

我正在嘗試使用select2來獲取遠程JSON數據並將其顯示爲多級別。 http://ivaynberg.github.io/select2/index.htmlselect2中的多選項

這是我的迴應

{ 
    "Company": [ 
    { 
     "name": "athenahealth Inc" 
    }, 
    { 
     "name": "Localiza Rent a Car" 
    }, 
    { 
     "name": "M and B Switchgears" 
    } 
    ], 
    "Functional": [ 
    { 
     "name": "arranger" 
    }, 
    { 
     "name": "ambassadors" 
    } 
    ], 
    "Persons": [ 
    { 
     "name": "Moustapha al" 
    }, 
    { 
     "name": "Saleh al" 
    } 
    ] 
} 

我要顯示的結果中多值格式 - http://ivaynberg.github.io/select2/index.html#multi

到目前爲止,我能夠來從服務器端的數據,但後來我有不知道如何啓用多重選擇選項。

回答

1

JSON在下面的格式將正常工作

相關的問題 - https://github.com/ivaynberg/select2/issues/58

{ "Data" : [ { 
      "id" :1 , 
      "text" : "Subsection" , 
      "children" : [{ 
        "id" : 2, 
        "text" : "Paru" 
         }, 
         { 
        "id" : 3, 
        "text" : "Vinu" 
         }] 
     }, 
      { "id" : 4 , 
      "text" : "Family" , 
      "children" : [{ 
        "id" : 5, 
        "text" : "ChildVM" 
         }, 
         { 
        "id" : 6, 
        "text" : "ChildPM" 
         }] 
     } 
      ]  
}