not be able to keep the same feature with a extra button with Editor

not be able to keep the same feature with a extra button with Editor

mromemrome Posts: 8Questions: 3Answers: 0

hi all,

i use Editor Datatable when i select rows from datatable et use button editor all works fine all details from each selected rows are send.

Now i have created a extra button but when i follow the sames steps all workfine but all rows from datatable are send but not only selected rows.

Below the code

Standard button

           editorcreateticket = new $.fn.dataTable.Editor( {
                ajax : {
                    url: '/sgp/editor/fiche',
                    data: function(d) {
                        d.action =  "ticket";
                    console.log("d: ",d);
                        },
                },
                table : '#tableSgp',
                idSrc : 'id',
                "events": '',
                fields: [ {
                    label : 'Nom du ticket',
                    name : 'libelle',
                     optionsPair: {
                        value: 'id',
                    }
                },
                {
                        label: "Typologie",
                        name:  "Typologie",
                        type:  "select",
                        options: [
                            { label: "",    value: "VIDE" },
                            { label: "Crée",    value: "Crée" },
                            { label: "Attribué",    value: "Attribué" },
                            { label: "En cours de traitement",   value: "En cours de traitement" },
                            { label: "Résolu",   value: "Résolu" },
                            { label: "Envoi en litige",   value: "Envoi en litige" },
                            { label: "Ecarts acceptés",   value: "Ecarts acceptés" }
                        ]
                },
                {
                    label : 'Commentaire',
                    name : 'commentaire',
                    // type : 'text',
                },
                {
                        label : 'Utilisateur',
                        name : 'users',
                        type : 'select',
                        multiEditable : true,
                        placeholder : 'Choisir un utilisateur'
                }

            } );

Extra Button

           $('#ticketButton').on('click', function (e) {
                e.preventDefault();
                var resultat = selected();
               console.log("resultat");
                editorcreateticket
                    .title('<br><H2><span style="color: black; font-family: Reckless Neue;">Créer un ticket</span></H2><br>'+ resultat[0]["count"]+ ' Fiches séléctionnées ... <p><span style="color: black;">Créez un ticket à partir des écarts sélectionnés. Vous pouvez vous l’attribuer ou l’attribuer à un responsable. <div class="container"><p>Exactitude</p><div class="progressbar-wrapper"> <div title="downloaded" class="progressbar mp4">64%</div></div></span></p>')
                    .ajax({
                    url: '/sgp/editor/fiche',
                        data: function(d) {
                        d.action =  "ticket";
                        console.log(d);
                    },
                })
                    //.table('#tableSgp')
                    //.idSrc('id')
                    .buttons([
                        {
                            label: 'Annuler',
                            className: 'closeButton',
                            action: function () {
                                var that = this;
                                setTimeout(function() {
                                    that.close();
                                }, 100);
                            }
                        },
                        {
                           label: 'Créer',
                        }])
                    .edit();
            } );

Could you tell me how repoduce the same feature only send selected rows to the server ?

Thank you for your help

Michel

Answers

  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin

    With edit() you need to tell it which rows you want to edit. Otherwise it wouldn't use any selector for the rows, which yes, results in all rows being picked up.

    What you want to do is:

    .edit(table.rows({selected:true}).indexes());
    

    (change table to the right variable name if needed).

    Regards,
    Allan

  • mromemrome Posts: 8Questions: 3Answers: 0

    hi allan,

    it's works

    You are great , you are a guru
    With you no issue only solution

    Thank you very much

    michel

  • mromemrome Posts: 8Questions: 3Answers: 0

    hi allan

    Another question in relation with your answer :
    table.rows({selected:true}).indexes() return only the indexes rows but using with Editor i receive to the server the complete rows like this :

    2023-03-17T11:36:46+0000 : $dataArray1 : array (
    31947 =>
    array (
    'users' => '2',
    'libelle' => 'ticket1',
    'commentaire' => '',
    'actionticket' => 'VIDE',
    'statut_produit' => 'apublier',
    ),
    31948 =>
    array (
    'users' => '2',
    'libelle' => 'ticket1',
    'commentaire' => '',
    'actionticket' => 'VIDE',
    'statut_produit' => 'apublier',

    Before the full treatment i would like run a prerun to execute specific treatment for this i use event preopen like this :
    editorcreateticket
    .on('preOpen', function(e, type) {
    setUserList("Fiche",editorcreateticket);
    getEcart(tableSgp.rows({selected:true}).indexes(),editorcreateticket);
    });

    but with this it is not correct i have only rows indexes but not the real information like 31947 and 31948

    How must proceed to have the same informations sended by editorcreateticket ?

    thank for your help

    Michel

Sign In or Register to comment.