Advertisement
Guest User

Test Code

a guest
Sep 5th, 2018
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.50 KB | None | 0 0
  1. $('#tabellaDestinazioni').DataTable( {
  2.             dom: `<"row"<"col-md-9"B><"col-md-3"f>>rt<"row"<"col-md-5"l><"col-md-2"i><"col-md-5"p>>`,
  3.             buttons: [
  4.                 {
  5.                     text: '<i class="fa fa-plus"></i> Nuova destinazione',
  6.                     className: "btn btn-simple btn-primary",
  7.                     action: function ( e, dt, node, config ) {
  8.                         editorDestinazioni.title("Nuova Destinazione").buttons("Salva").create();
  9.                     }
  10.                 },
  11.                 {
  12.                     text: '<i class="fa fa-edit"></i> Modifica destinazione',
  13.                     className: "btn btn-simple btn-warning",
  14.                     extend: "editSingle",
  15.                     editor: editorDestinazioni,
  16.                     formButtons: ["Salva"],
  17.                     formTitle: (editor, dt) => {
  18.                         let rowData = dt.row({selected:true}).data();
  19.                         return 'AGGIORNA '+rowData.nomeDestinazione;
  20.                     }
  21.                 },
  22.                 {
  23.                     text: '<i class="fa fa-times"></i> Elimina destinazione',
  24.                     className: "btn btn-simple btn-danger",
  25.                     extend: "remove",
  26.                     editor: editorDestinazioni,
  27.                     formTitle: (editor, dt) => {
  28.                         let rowData = dt.row({selected:true}).data();
  29.                         return 'ELIMINA '+rowData.nomeDestinazione;
  30.                     },
  31.                     formMessage: "Sei sicuro di voler continuare?",
  32.                     formButtons: ["Elimina", {
  33.                         text: "Annulla",
  34.                         action: () => {
  35.                             editorDestinazioni.close();
  36.                         }
  37.                     }]
  38.                 }
  39.             ],
  40.             select: {
  41.                 style: 'os',
  42.                 selector: 'td:not(:last-child)' // no row selection on last column
  43.             },
  44.             serverSide: true,
  45.             ajax: `{{ route("datatables.clienti.destinazioni", ["id" => $cliente->id]) }}`,
  46.             language: {
  47.                 processing:     "Caricamento...",
  48.                 search:         "Cerca ",
  49.                 info:           "Da _START_ a _END_ di _TOTAL_ destinazioni",
  50.                 infoEmpty:      "Vista da 0 a 0 di 0 destinazioni",
  51.                 lengthMenu:     "Visualizza _MENU_ destinazioni",
  52.                 loadingRecords: "Caricamento...",
  53.                 zeroRecords:    "Nessuna destinazione trovata!",
  54.                 emptyTable:     "Nessuna destinazione trovata",
  55.                 paginate: {
  56.                     first:      "Prima",
  57.                     previous:   "Indietro",
  58.                     next:       "Avanti",
  59.                     last:       "Ultima"
  60.                 },
  61.                 select: {
  62.                     rows: {
  63.                         _: "",
  64.                     }
  65.                 }
  66.             },
  67.             columns: [
  68.                 { "data": "nomeDestinazione", sortable: false},
  69.                 { "data": "indirizzo", sortable: false},
  70.                 { "data": "citta", sortable: false},
  71.                 { "data": "cap", sortable: false},
  72.                 { "data": "provincia", sortable: false},
  73.                 { "data": "telefono", sortable: false, defaultValue: ""},
  74.                 {
  75.                     data:   null,
  76.                     render: function ( data, type, row ) {
  77.                         if ( type === 'display' ) {
  78.                             return `<div class="checkbox">
  79.                                         <input id="checkbox-${data.id}" type="checkbox" class="editor-active">
  80.                                         <label for="checkbox-${data.id}"></label>
  81.                                      </div>`;
  82.                         }
  83.                         return data.active;
  84.                     },
  85.                     className: "dt-body-center",
  86.                     sortable: false,
  87.                     searchable: false
  88.                 }
  89.             ],
  90.             "initComplete": () => {
  91.                 /*$('#tabellaDestinazioni').on( 'click', 'tbody td:not(:last-child)', function (e) {
  92.                     editorDestinazioni.inline( this );
  93.                 } );*/
  94.             },
  95.             rowCallback: function ( row, data ) {
  96.                 // Set the checked state of the checkbox in the table
  97.                 $('input.editor-active', row).prop( 'checked', data.active == 1 );
  98.             }
  99.         } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement