我正在尝试对DataTables使用TreeGrid扩展名。我试图重现此处给出的示例:https://homfen.github.io/dataTables.treeGrid.js/。
我有此代码:
<script type="text/javascript" src='{{ asset(' js/DataTables/media/js/jquery.js ') }}'></script>
<script type="text/javascript" src='{{ asset(' js/DataTables/media/js/jquery.dataTables.min.js ') }}'></script>
<script type="text/javascript" src='{{ asset(' js/dataTables.treeGrid/dataTables.treeGrid.js ') }}'></script>
<script>
var columns = [{
title: '',
target: 0,
className: 'treegrid-control',
data: function(item) {
if (item.children) {
return '<span>+</span>';
}
return '';
}
}, {
title: 'Name',
target: 1,
data: function(item) {
return item.name;
}
}, {
title: 'Position',
target: 2,
data: function(item) {
return item.position;
}
}, {
title: 'Office',
target: 3,
data: function(item) {
return item.office;
}
}, {
title: 'Extn.',
target: 4,
data: function(item) {
return item.extn;
}
}, {
title: 'Start date',
target: 5,
data: function(item) {
return item.start;
}
}, {
title: 'Salary',
target: 6,
data: function(item) {
return item.salary;
}
}];
$('#example').DataTable({
'columns': columns,
'ajax': "{{ asset('js/arrays.json') }}",
'treeGrid': {
'left': 10,
'expandIcon': '<span>+</span>',
'collapseIcon': '<span>-</span>'
}
});
</script>
在我的显示中,我有这个:display
我的问题是,当我单击+
或-
时,我的控制台中显示以下消息:
Error in console
[Afficher / Masquer lesdétailsdu message。] TypeError:数据未定义[Ensavoir plus] dataTables.treeGrid.js:140:1fnConstruct / < http://localhost/gestion_MKT/web/js/dataTables.treeGrid/dataTables.treeGrid.js:140:1 调度 http://localhost/gestion_MKT/web/js/DataTables/media/js/jquery.js:3:12392 添加/r.handle http://localhost/gestion_MKT/web/js/DataTables/media/js/jquery.js:3:9156“