Sorting value is come from joined table, not working editor drag and drop sorting.
Sorting value is come from joined table, not working editor drag and drop sorting.
bumanerdene
Posts: 2Questions: 1Answers: 0
My client side defined like this. I am using Laravel in server side. I am new to Datatable, I really don't idea what is the problem.
editor = new $.fn.dataTable.Editor( {
ajax: {{ route('words.dt', $baseklass->id) }},
table: '#m_table_1',
fields: [ {
label: 'Order:',
name: 'sort.sort',
fieldInfo: 'This field can only be edited via click and drag row reordering.'
}, {
label: 'Word:',
name: 'word.word'
}, {
label: 'Key word:',
name: 'keyword.0.key_word'
}, {
label: 'Translation',
name: 'word_translation.0.translation'
},{
label: "Image:",
name: 'image[].id',
type: "upload",
dragDrop: false,
display: function ( image ) { return image.length},
clearText: "Clear",
noImageText: 'No image '
}
]
} );
~~~~
var table = $('#m_table_1').DataTable( {
dom: 'Bfrtip',
"pageLength": 100,
ajax: '{{ route('words.dt', $baseklass->id) }}',
columns: [
{ data: 'sort.sort', className: 'reorder' },
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: 'word.word' },
{ data: "keyword.0.key_word",
editField: "keyword.0.key_word",
render: function(data){
return data? data:'No keyword'
}
},
{ data: 'word_translation.0.translation',
editField: "word_translation.0.translation",
render: function(data){
return data? data:'No translation'
}
},
{
data: "image[].image",
editField: false,
render: function ( data ) {
return data? '<img class="img" src="/storage/'+data[0]+'"/>':'No image!';
},
},
],
columnDefs: [
{ orderable: false, targets: [ 1,2,3 ] }
],
rowReorder: {
dataSrc: 'sort.sort',
editor: editor
},
responsive: {
details: {
type: 'column',
target: 1
}
},
select: true,
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
],
} );
Issue is drag drop working but not request sending to server side and data swapping but value is not changing(after new refresh it comes old again).
In addition Sort is comes from joined table not actually main table.
\DataTables\Editor::inst( $db, 'word')
->fields(
Field::inst( 'word.word' ),
Field::inst( 'sort.sort' )
->validator( 'Validate::numeric' ),
Field::inst( 'word_category.baseklass_id' )
)
->leftJoin('sort', 'sort.word_id', '=', 'word.id')
This discussion has been closed.
Replies
Could you give me a link to your page so I can help to debug it please. I don't immediately see what is going wrong there, so I would need to be able to see the page to debug it.
Allan