【问题标题】:Multi options in select2select2中的多个选项
【发布时间】:2013-05-11 16:53:37
【问题描述】:

我正在尝试使用 select2 来获取远程 JSON 数据并以多级显示它。 http://ivaynberg.github.io/select2/index.html

这是我的回应

{
  "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

到目前为止,我能够从服务器端获取数据,但是我不知道如何启用多选选项。

【问题讨论】:

    标签: javascript jquery-select2


    【解决方案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"
                          }]
            }
               ]    
    }    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-10
      • 2019-08-16
      • 2017-06-25
      • 1970-01-01
      相关资源
      最近更新 更多