我想初始化fancyTree,什么都没发生。数据将通过ajax加载,在chrome的开发工具中,我可以看到ajax响应成功返回,但是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>发布于 2020-12-16 13:44:24
我发现了问题。问题是,json响应包含重复的键,无法处理花式树。
https://stackoverflow.com/questions/64871573
复制相似问题