Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#tabellaDestinazioni').DataTable( {
- dom: `<"row"<"col-md-9"B><"col-md-3"f>>rt<"row"<"col-md-5"l><"col-md-2"i><"col-md-5"p>>`,
- buttons: [
- {
- text: '<i class="fa fa-plus"></i> Nuova destinazione',
- className: "btn btn-simple btn-primary",
- action: function ( e, dt, node, config ) {
- editorDestinazioni.title("Nuova Destinazione").buttons("Salva").create();
- }
- },
- {
- text: '<i class="fa fa-edit"></i> Modifica destinazione',
- className: "btn btn-simple btn-warning",
- extend: "editSingle",
- editor: editorDestinazioni,
- formButtons: ["Salva"],
- formTitle: (editor, dt) => {
- let rowData = dt.row({selected:true}).data();
- return 'AGGIORNA '+rowData.nomeDestinazione;
- }
- },
- {
- text: '<i class="fa fa-times"></i> Elimina destinazione',
- className: "btn btn-simple btn-danger",
- extend: "remove",
- editor: editorDestinazioni,
- formTitle: (editor, dt) => {
- let rowData = dt.row({selected:true}).data();
- return 'ELIMINA '+rowData.nomeDestinazione;
- },
- formMessage: "Sei sicuro di voler continuare?",
- formButtons: ["Elimina", {
- text: "Annulla",
- action: () => {
- editorDestinazioni.close();
- }
- }]
- }
- ],
- select: {
- style: 'os',
- selector: 'td:not(:last-child)' // no row selection on last column
- },
- serverSide: true,
- ajax: `{{ route("datatables.clienti.destinazioni", ["id" => $cliente->id]) }}`,
- language: {
- processing: "Caricamento...",
- search: "Cerca ",
- info: "Da _START_ a _END_ di _TOTAL_ destinazioni",
- infoEmpty: "Vista da 0 a 0 di 0 destinazioni",
- lengthMenu: "Visualizza _MENU_ destinazioni",
- loadingRecords: "Caricamento...",
- zeroRecords: "Nessuna destinazione trovata!",
- emptyTable: "Nessuna destinazione trovata",
- paginate: {
- first: "Prima",
- previous: "Indietro",
- next: "Avanti",
- last: "Ultima"
- },
- select: {
- rows: {
- _: "",
- }
- }
- },
- columns: [
- { "data": "nomeDestinazione", sortable: false},
- { "data": "indirizzo", sortable: false},
- { "data": "citta", sortable: false},
- { "data": "cap", sortable: false},
- { "data": "provincia", sortable: false},
- { "data": "telefono", sortable: false, defaultValue: ""},
- {
- data: null,
- render: function ( data, type, row ) {
- if ( type === 'display' ) {
- return `<div class="checkbox">
- <input id="checkbox-${data.id}" type="checkbox" class="editor-active">
- <label for="checkbox-${data.id}"></label>
- </div>`;
- }
- return data.active;
- },
- className: "dt-body-center",
- sortable: false,
- searchable: false
- }
- ],
- "initComplete": () => {
- /*$('#tabellaDestinazioni').on( 'click', 'tbody td:not(:last-child)', function (e) {
- editorDestinazioni.inline( this );
- } );*/
- },
- rowCallback: function ( row, data ) {
- // Set the checked state of the checkbox in the table
- $('input.editor-active', row).prop( 'checked', data.active == 1 );
- }
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement