Select 2 4.0 分层数据协助
Select 2 4.0 Hirearchical Data Assistance
所以我一直在尝试在 Select2 组件中获取分层数据。但它只是dosen似乎工作。我以前用过Select2,我觉得代码是一样的,在Select 2 4.0中数据不会显示。
var data = [
{
"description" : "Parent" ,
"children" : [
{
"description" :"Child 1",
"id" : "11",
"children" : [
{
"description" : "Grandchild 1",
"id" : "111"
},
{
"description" : "Grandchild 2",
"id" : "112"
}
]
},
{
"description" :"Child 2",
"id" : "12",
"children" : [
{
"description" : "Grandchild 1",
"id" : "121"
},
{
"description" : "Grandchild 2",
"id" : "122"
}
]
}
],
"id" : "1"
}
];
function descFormatResult(item) {
}
function descFormatSelection(item) {
return item.description;
}
$("#e10_2").select2({
matcher: function (term, text) {
return text.toUpperCase().indexOf(term.toUpperCase()) === 0;
},
placeholder: "Location",
minimumInputLength: 0,
data:{
results: data,
text : "description"
},
escapeMarkup: function (text) {
return text;
},
templateResult: descFormatResult
});
我这里有一个 fiddle JSFiddle
任何帮助都将非常感谢。
“此版本包含许多重大更改,但已创建易于升级的路径以及帮助模块,这些模块将允许与过去版本的 Select2 保持向后兼容性。升级将需要您阅读发行说明仔细,但迁移路径应该相对简单。您可以在 release notes." - https://select2.github.io/announcements-4.0.html
中查看需要进行的最常见更改的列表
所以我一直在尝试在 Select2 组件中获取分层数据。但它只是dosen似乎工作。我以前用过Select2,我觉得代码是一样的,在Select 2 4.0中数据不会显示。
var data = [
{
"description" : "Parent" ,
"children" : [
{
"description" :"Child 1",
"id" : "11",
"children" : [
{
"description" : "Grandchild 1",
"id" : "111"
},
{
"description" : "Grandchild 2",
"id" : "112"
}
]
},
{
"description" :"Child 2",
"id" : "12",
"children" : [
{
"description" : "Grandchild 1",
"id" : "121"
},
{
"description" : "Grandchild 2",
"id" : "122"
}
]
}
],
"id" : "1"
}
];
function descFormatResult(item) {
}
function descFormatSelection(item) {
return item.description;
}
$("#e10_2").select2({
matcher: function (term, text) {
return text.toUpperCase().indexOf(term.toUpperCase()) === 0;
},
placeholder: "Location",
minimumInputLength: 0,
data:{
results: data,
text : "description"
},
escapeMarkup: function (text) {
return text;
},
templateResult: descFormatResult
});
我这里有一个 fiddle JSFiddle
任何帮助都将非常感谢。
“此版本包含许多重大更改,但已创建易于升级的路径以及帮助模块,这些模块将允许与过去版本的 Select2 保持向后兼容性。升级将需要您阅读发行说明仔细,但迁移路径应该相对简单。您可以在 release notes." - https://select2.github.io/announcements-4.0.html
中查看需要进行的最常见更改的列表