editor.dependent and multiselect field in editor?
editor.dependent and multiselect field in editor?
mf
Posts: 41Questions: 11Answers: 0
in Responsive
Dear all, I hope somebody can help me on the way, how can I send the values of dealers[].dealernr ? I know it is an array but I don't know how to make it dependent.
Should it be something like dealers['0'].dealernr? tried that though, its not working, thanks!
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
ajax: 'php/table.bezoekverslagen.php',
table: '#bezoekverslagen',
fields: [
{ "label": "dealernr(s) multiselect:",
"name" : "dealers[].dealernr",
"type": "select",
"multiple": true,
"placeholder": "Maak een selectie"},
{ "label": "contact(s) multiselect:",
"name" : "dealercontacts[].dealercontacts_id",
"type": "select",
"multiple": true,
"placeholder": "Maak een selectie"},
{ "label": "bezoekdatum:",
"name": "bezoekverslagen.bezoekdatum",
"type": "datetime",
"def": "0000-00-00",
"format": "YYYY-MM-DD" },
{ "label": "task:",
"name": "bezoekverslagen.task",
"type": "select",
"options": ["telefoon in","telefoon uit","bezoek in","bezoek uit"]},
{ "label": "beschrijving:",
"name": "bezoekverslagen.beschrijving",
"type": "textarea"},
{ "label": "afspraak:",
"name": "bezoekverslagen.afspraak"},
{ "label": "opvolgen:",
"name": "bezoekverslagen.opvolgen",
"type": "datetime",
"def": "0000-00-00",
"format": "YYYY-MM-DD"},
{ "label": "associate_id:",
"name": "bezoekverslagen.associate_id"},
{ "label": "voltooid:",
"name": "bezoekverslagen.voltooid",
"type": "checkbox",
"separator": "|",
"options": [ { "label": '', "value": 1 } ]
}
]
} );
var table = $('#bezoekverslagen').DataTable( {
dom: 'Bfrtip',
ajax: 'php/table.bezoekverslagen.php',
columns: [
{ "data": "dealers", "render": "[, ].naam" },
{ "data": "dealercontacts", "render": "[, ].lastname" },
{ "data": "bezoekverslagen.bezoekdatum"},
{ "data": "bezoekverslagen.task"},
{ "data": "bezoekverslagen.beschrijving"},
{ "data": "bezoekverslagen.afspraak"},
{ "data": "bezoekverslagen.opvolgen"},
{ "data": "bezoekverslagen.associate_id"},
{ "data": "bezoekverslagen.voltooid", render: function ( data, type, row ) { if ( type === 'display' ) { return '<input type="checkbox" class="editor-active">'; } return data; }, className: "dt-body-center" }
],
select: {
style: 'os',
selector: 'td:not(:last-child)' // no row selection on last column
},
rowCallback: function ( row, data ) {
$('input.editor-active', row).prop( 'checked', data.bezoekverslagen.voltooid == 1 );
},
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
]
} );
//editor.dependent( 'dealers[].dealernr', 'contacts_dynamic.php' ); <--- this will not work!!
$('#bezoekverslagen').on( 'change', 'input.editor-active', function () {
editor
.edit( $(this).closest('tr'), false )
.set( 'bezoekverslagen.voltooid', $(this).prop( 'checked' ) ? 1 : 0 )
.submit();
} );
} );
This discussion has been closed.
Answers
sorry, I accidentally posted this question in responsive and I can't change it.
I think my problem is in contacts_dynamic.php :
$dlr = $_REQUEST['values']['dealers[].dealernr'];
$dlr is empty I think, its not really empty but I am not getting any values
this is the form data
rows=&row=&values%5Bbezoekverslagen.bezoekdatum%5D=&values%5Bbezoekverslagen.task%5D=telefoon+in&values%5Bbezoekverslagen.beschrijving%5D=&values%5Bbezoekverslagen.afspraak%5D=&values%5Bbezoekverslagen.opvolgen%5D=&values%5Bbezoekverslagen.associate_id%5D=&values%5Bbezoekverslagen.voltooid%5D=
So maybe its not possible to get the value of dealers[].dealernr ?
correction, I do see postdata like this:
row[dealers][0][dealernr]: 12415
row[dealers][0][naam]: Autobedrijf Peter Ursem Purmerend B
row[dealers][1][dealernr]: 12416
row[dealers][1][naam]: Autobedrijf Peter Ursem Schagen B.V
values[dealers[].dealernr][]: 11251
values[dealers[].dealernr][]: 11250
but $dlr = $_REQUEST['values']['dealers[].dealernr']; seems empty though
I have this in contacts_dynamic.php
```
<?php > ``` It sort of works but I only get 1 number at the time, so if you select more dealers, you don't get more then one dealer in the post data ?><?php
include_once( "dbconfig.php" );