How to update edited row ?
How to update edited row ?
sumanthbhe
Posts: 4Questions: 2Answers: 0
Hi, after clicking on submit for is not updated. In console network error is 403
Forbidden. How to update edited row ?
var workorder_path = "/dashboard/workorder_list/0/?format=json";
var editor = new $.fn.dataTable.Editor( {
ajax: {
edit: {
type: 'PUT',
dataType:"json",
contentType: "application/json",
url: '/dashboard/workorder_list/0/?format=json',
data: function ( d ) {
return JSON.stringify( d );
}
},
},
table: "#workorder_table",
idSrc: "id",
fields: [
{ label: "ID:", name: "id" },
{ label: "Task:", name: "task.name" },
{ label: "Description:", name: "description" },
{ label: "Start Date:", name: "start_date",
"type": "datetime" },
{ label: "End Date:", name: "end_date",
"type": "datetime" }
]
} );
var workorder_table = $('#workorder_table').dataTable({
dom: 'Blfrtip',
JQueryUI: true,
bPaginate: false,
sScrollX: "100%",
responsive: true,
select: true,
buttons: [
{
text: 'New',
action: function () {
create_workorder_window();
},
className: 'btn btn-warning btn-outline'
},
{ extend: "edit", editor: editor, className: 'btn btn-warning btn-outline' },
// { extend: "create", editor: editor },
{ extend: 'colvis', text: 'Show', className: 'btn btn-warning btn-outline'}
],
ajax: {
url: workorder_path,
dataSrc: ''
},
columns: [
{"data": "id", "class": "workorder_id"},
{"data": "thumb", "render": function(data, type, row) {
return `<a href=` + data + ` data-fancybox> <img src=` + data + ` width="80" height="45"> </a>`;
}},
{"data": "task.name"},
{"data": "description"},
{"data": "status", "class":"v-a-m", "render": function (status, type, row) {
return `<div class="media media-auto">
<div class="media-left">
<div class="avatar">
<img class="media-object img-circle"
src=${ status.image }
alt=${ status.name }
title=${ status.name }>
</div>
</div>
<div class="media-body">
<span class="media-heading">${ status.name }</span>
</div>
</div>`;
} },
{"data": "start_date", "visible": false},
{"data": "end_date", "visible": false},
{"data": "assign_to", "width": "400px", "defaultContent": "None", "render": function (assign_to, type, row) {
return `<div class="media media-auto">
<div class="media-left">
<div class="avatar">
<img class="media-object img-circle"
src=${ assign_to.photo }
alt=${ assign_to.official_name }>
</div>
</div>
<div class="media-body">
<span class="media-heading text-white">${ assign_to.official_name }</span>
<br>
<span class="text-gray-lighter"><span>${ assign_to.designation.designation }</span></span>
</div>
</div>`
} },
{"data": "creation_time", "visible": false},
{"data": "modified_time", "visible": false}
]
});
This discussion has been closed.
Answers
You need to establish why you are getting 403 Forbidden. Is your target directory not writable, for example?
Perhaps user not logged in or the user doesn't have write access?
Allan