FancyTree 未初始化
FancyTree not initialize
我想初始化fancyTree,没有任何反应。
数据将通过 ajax 加载,在 chrome 的开发人员工具中我可以看到,ajax 响应 returns 成功,但 fancytree 不会呈现响应。
上周它工作正常,但本周没有任何反应。我没有改密码!
这里是我的 javascript 代码:
$('#document-tree').fancytree({
extensions: ["table"],
source: $.ajax({
url: '/pdm/document/getDocumentByItem.do?item-number=' + itemNumber
}),
debugLevel: 4, // 0:quiet, 1:errors, 2:warnings, 3:infos, 4:debug
selectMode: 2, // 1:single, 2:multi, 3:multi-hier
checkbox: true, // Show check boxes
tooltip: true, // Use title as tooltip (also a callback could be specified)
titlesTabbable: true, // Add all node titles to TAB chain
autoScroll: true,
table: {
indentation: 20, // indent 20px per node level
nodeColumnIdx: 2, // render the node title into the 2nd column
checkboxColumnIdx: 0, // render the checkboxes into the 2nd column
},
renderColumns: function(event, data) {
var node = data.node,
$tdList = $(node.tr).find(">td");
// (index #0 is rendered by fancytree by adding the checkbox)
$tdList.eq(1).text(node.getIndexHier()); //.addClass("alignRight");
// (index #2 is rendered by fancytree)
$tdList.eq(3).text(node.data.documentIndex);
if (node.data.documentCategory != null)
{
var categoryName = node.data.documentCategory.name;
if (node.data.documentCategory.singleSubCategory != null)
{
categoryName += " -> " + node.data.documentCategory.singleSubCategory.name;
}
$tdList.eq(4).text(categoryName);
}
$tdList.eq(5).text(volante.formatDate(node.data.createdAt, 1));
if (node.isActive())
{
nodeActive(node.data);
}
if (node.isSelected())
{
var array = [];
array.push(node);
nodeSelected(array);
}
},
activate: function (event, data)
{
nodeActive(data.node.data);
},
select: function(event, data)
{
nodeSelected(data.tree.getSelectedNodes());
},
init: function (event, data)
{
if (data.tree.count() > 0)
{
$('#document-empty').addClass('d-none');
$('#document-file-tree').removeClass('d-none');
}
}
});
这里是html
的代码
<table id="document-tree">
<thead>
<tr>
<th></th>
<th>Row</th>
<th>Document name</th>
<th>Index</th>
<th>Category</th>
<th>Created at</th>
</tr>
</thead>
</table>
我发现了问题。问题是,json 响应包含重复键,无法处理花式树。
我想初始化fancyTree,没有任何反应。 数据将通过 ajax 加载,在 chrome 的开发人员工具中我可以看到,ajax 响应 returns 成功,但 fancytree 不会呈现响应。 上周它工作正常,但本周没有任何反应。我没有改密码!
这里是我的 javascript 代码:
$('#document-tree').fancytree({
extensions: ["table"],
source: $.ajax({
url: '/pdm/document/getDocumentByItem.do?item-number=' + itemNumber
}),
debugLevel: 4, // 0:quiet, 1:errors, 2:warnings, 3:infos, 4:debug
selectMode: 2, // 1:single, 2:multi, 3:multi-hier
checkbox: true, // Show check boxes
tooltip: true, // Use title as tooltip (also a callback could be specified)
titlesTabbable: true, // Add all node titles to TAB chain
autoScroll: true,
table: {
indentation: 20, // indent 20px per node level
nodeColumnIdx: 2, // render the node title into the 2nd column
checkboxColumnIdx: 0, // render the checkboxes into the 2nd column
},
renderColumns: function(event, data) {
var node = data.node,
$tdList = $(node.tr).find(">td");
// (index #0 is rendered by fancytree by adding the checkbox)
$tdList.eq(1).text(node.getIndexHier()); //.addClass("alignRight");
// (index #2 is rendered by fancytree)
$tdList.eq(3).text(node.data.documentIndex);
if (node.data.documentCategory != null)
{
var categoryName = node.data.documentCategory.name;
if (node.data.documentCategory.singleSubCategory != null)
{
categoryName += " -> " + node.data.documentCategory.singleSubCategory.name;
}
$tdList.eq(4).text(categoryName);
}
$tdList.eq(5).text(volante.formatDate(node.data.createdAt, 1));
if (node.isActive())
{
nodeActive(node.data);
}
if (node.isSelected())
{
var array = [];
array.push(node);
nodeSelected(array);
}
},
activate: function (event, data)
{
nodeActive(data.node.data);
},
select: function(event, data)
{
nodeSelected(data.tree.getSelectedNodes());
},
init: function (event, data)
{
if (data.tree.count() > 0)
{
$('#document-empty').addClass('d-none');
$('#document-file-tree').removeClass('d-none');
}
}
});
这里是html
的代码<table id="document-tree">
<thead>
<tr>
<th></th>
<th>Row</th>
<th>Document name</th>
<th>Index</th>
<th>Category</th>
<th>Created at</th>
</tr>
</thead>
</table>
我发现了问题。问题是,json 响应包含重复键,无法处理花式树。