При нажатии на кнопку редактирования выдается ошибка, никак не могу понять в чем дело. Гуглил очень долго, решения своей проблемы найти не смог(
Код таблицы с редактором:
(function($){
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
"ajax": {
"url": "/public//index.html.php?api=add",
"dataSrc": ""
},
i18n: {
create: {
title: "Добавление нового продукта",
},
edit:{
title: "Редактирование продукта",
}
},
table: "#goodsTable",
fields: [ {
label: "Артикул:",
name: "article"
}, {
label: "Название:",
name: "title"
}, {
label: "Цена:",
name: "price",
}, {
label: "img:",
name: "img",
type: 'upload',
dragDropText: "Вы можете просто перетащить файл",
uploadText:"Выбрать файл",
display: function ( id ) {
return '<img src="'+editor.file( 'img', id ).webPath+'"/>';
},
noImageText: 'Нет изображения'
}, {
label: "Оипсание:",
name: "description"
},
],
} );
var table = $('#goodsTable').DataTable( {
dom: "Bfrtip",
select : 'single',
language: {
info: "Показан(о) _START_ из _TOTAL_ продуктов",
search:"поиск",
"paginate": {
"first": "Следущая страница",
"next": "Далее",
"previous": "В начало"
},
},
"ajax": {
"url": "/public//index.html.php?api=goods",
"dataSrc": ""
},
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: "article" , title: "арктикл"},
{ data: "title" , title: "название"},
{ data: "price" , title: "цена (руб)"},
{
data: "img" ,
title: "img",
// render: function ( file_id ) {
// return file_id ?
// '<img src="'+editor.file( 'files', file_id ).web_path+'"/>' :
// null;
// },
defaultContent: "Нет изображения",
},
{ data: "description" , title: "описание", defaultContent: "Нет описания",},
],
buttons: [
{
extend: "create",
editor: editor,
text: "создать",
formButtons: [
{ text: 'Сохранить', action: function () { this.submit()}},
{ text: 'Закрыть', action: function () { this.close()}}
],
},
{ extend: "edit", editor: editor, text: "редактировать" },
{ extend: "remove", editor: editor, text: "удалить" }
]
} );
} );
}(jQuery));
Таблица:
<table id="goodsTable" class="display table table-striped table-bordered">
<thead>
<tr>
</tr>
</thead>
<tbody>
<tr>
<td>article</td>
<td>title</td>
<td>price</td>
<td>img</td>
<td>description</td>
</tr>
</tbody>
</table>
Сама ошибка:
Uncaught TypeError: Cannot read property '_fnGetObjectDataFn' of undefined
at Editor.fields (dataTables.editor.min.js:21)
at Editor.<computed>.<computed> [as _dataSource] (dataTables.editor.min.js:21)
at Editor.<computed>.<computed> [as edit] (dataTables.editor.min.js:21)
at D.action (dataTables.editor.min.js:21)
at g (datatables.min.js:232)
at HTMLButtonElement.<anonymous> (datatables.min.js:233)
at HTMLButtonElement.dispatch (datatables.min.js:14)
at HTMLButtonElement.y.handle (datatables.min.js:14)