Inline editing on table with 2 select box

Inline editing on table with 2 select box

yvan.nguyenyvan.nguyen Posts: 1Questions: 0Answers: 0
edited April 2016 in Bug reports

i have a Datatable with 2 select-box field for each row.
I tried to improve the "inline editing" on this table.

This is my Datatable-code:

<script type="text/javascript" class="init">
var editor; 
 
$jQuery(document).ready(function() {
    editor = new $jQuery.fn.dataTable.Editor( {
        ajax: "http://.../valori_report.php",
        table: "#ga_table",
        fields: [
            {
                label: "Partner",
                name:  "report_configurazione.vtiger_ref",
                type:  "select"
            },{
                label: "Progetto:",
                name:  "report_configurazione.progetto",
                type:  "select"
            }, {
                label: "Stato:",
                name:  "report_configurazione.stato",
                type:  "select"
            }, {
                label: "Email:",
                name:  "report_configurazione.email",
                fieldInfo: "Separare email differenti con ;"
            }, {
                label: "Storno Extra:",
                name:  "report_configurazione.sconto_base",
            }
        ],
     i18n: {
                edit: {
                    title:  "MODIFICA CONFIGURAZIONE",
                    button: "Modifica",
                    submit: "Modifica"
                },
                create: {
                        button: "Nuovo",
                        title:  "INSERISCI NUOVA CONFIGURAZIONE",
                        submit: "Inserisci"
                    },
                remove: {
                        button: "Elimina",
                        title:  "Elimina",
                        submit: "Elimina",
                        confirm: {
                            _: "Sei sicuro di voler eliminare %d configurazioni?",
                            1: "Sei sicuro di voler eliminare questa configurazione?"
                        }
                    },
                error: {
                    system: "Attenzione - Si è verificato un errore di sistema"
                }
    
            }
    } );
    
    
    // Activate an inline edit on click of a table cell
    $jQuery('#ga_table').on( 'click', 'tbody td', function (e) {
        editor.inline( this, {
            onBlur: 'submit'
        } );
    } );
 
    $jQuery('#ga_table').dataTable( {
        dom: "Tfrtip",
        pageLength: 20,
        ajax: {
            url: "http://.../valori_report.php",
            type: 'POST'
        },
        columns: [
            
            { data: "fornitori_vtiger.nome" , editField: "report_configurazione.vtiger_ref" },
            { data: "ga_progetti.progetto_nome" , editField: "report_configurazione.progetto" },
            { data: "report_fornitori_status.stato" , editField: "report_configurazione.stato" },
            { data: "report_configurazione.email" },
            { data: "report_configurazione.sconto_base" }
        ],
        tableTools: {
            sRowSelect: "os",
            aButtons: [
                { sExtends: "editor_create", editor: editor },
                { sExtends: "editor_edit",   editor: editor },
                { sExtends: "editor_remove", editor: editor }
            ]
        },
         language: {
            processing:     "Ricerca in corso...",
            search:         "Cerca:",
            lengthMenu:     "Visualizza _MENU_ righe per pagina",
            info:           "Da _START_ a _END_ di _TOTAL_ righe --- Pagina _PAGE_ di _PAGES_",
            infoEmpty:      "Nessun risultato!",
            infoFiltered:   "(filtrati da _MAX_ righe totali)",
            infoPostFix:    "",
            loadingRecords: "Ricerca in corso...",
            zeroRecords:    "Nessun risultato!",
            emptyTable:     "Nessun risultato!",
            paginate: {
                first:      "Primo",
                previous:   "<<",
                next:       ">>",
                last:       "Ultimo"
            }
        }
    } );
} );

</script>

For "text" field everything works but i have a problem with 2 select-box.
Although i change the value of any select-box, the value won't be saved in the table.

This is my php source (valori_report.php):

Editor::inst( $db, 'report_configurazione' )
    ->field(
            
        Field::inst( 'report_configurazione.progetto' )
        ->options( 'ga_progetti', 'id', 'progetto_nome' ),
        Field::inst( 'ga_progetti.progetto_nome' ),
            
        
        Field::inst( 'report_configurazione.email' )->validator( 'Validate::notEmpty',  array('message' => 'Campo Email Obbligatorio')),
        Field::inst( 'report_configurazione.sconto_base' )->validator( 'Validate::notEmpty',  array('message' => 'Campo Storno Extra Obbligatorio')),    
            
            
        Field::inst( 'report_configurazione.stato' )
            ->options( 'report_fornitori_status', 'id', 'stato' ),
        Field::inst( 'report_fornitori_status.stato' ),
            
            
        Field::inst( 'report_configurazione.vtiger_ref' )
            ->options( 'fornitori_vtiger', 'fornitore_vtigerid', 'nome' ),
        Field::inst( 'fornitori_vtiger.nome' )
            
            
    )
    ->leftJoin( 'fornitori_vtiger', 'fornitori_vtiger.fornitore_vtigerid', '=', 'report_configurazione.vtiger_ref' )    
    ->leftJoin( 'report_fornitori_status', 'report_fornitori_status.id', '=', 'report_configurazione.stato' )
    ->leftJoin( 'ga_progetti', 'ga_progetti.id', '=', 'report_configurazione.progetto')     
        
        
        
        
    ->process($_POST)
    ->json();

I can't find the way for solve this problem.
Can anyone help me?

Thanks

Replies

  • allanallan Posts: 61,436Questions: 1Answers: 10,049 Site admin

    Thanks for the code. It looks like it should submit to the server whenever you click outside the select box due to the use of onBlur: 'submit'. Does it make an Ajax request at that point?

    Can you give me a link to the page so I can debug it please?

    Allan

This discussion has been closed.