Use an idSrc for each field, or several IdScr in the same datatables

Use an idSrc for each field, or several IdScr in the same datatables

FrChFGoFrChFGo Posts: 22Questions: 5Answers: 0

Hi,
I have to display and edit fields of several Entities in the same datatables.
Display works :-)
Is it possible to define a different idSrc for each field or for a group of fields?
What's the best way? Make several editors fonctions (one for each table to update)?

my code for Editor:

          var insertEditor;

                insertEditor = new $.fn.dataTable.Editor({
                ajax: "@Url.RouteUrl( new { controller = "Conception_faisceau", action = "_InsertDatatablesAction" })",
                idSrc: "insert.id",
                table: "#insertTable",
                fields: [
                    {
                        label: "@Language.INSERT_id",
                        name: "insert.id",
                        type: "hidden"
                    },{
                        label: "@Language.INSERT_etat",
                        name: "insert.etat",
                        type: "hidden"
                    },{
                        label: "@Language.CIRCUITFAISCEAU_idTypeFluideListe",
                        name: "circuitFaisceau.idTypeFluideListe",
                        type: "readonly"
                    }, {
                        label: "@Language.PLAQUE_idTypePlaqueListe",
                        name: "plaque.idTypePlaqueListe",
                        type: "readonly"
                    },{
                        label: "@Language.INSERT_idCoteCircuitFaisceauListe",
                        name: "insert.idCoteCircuitFaisceauListe",
                        type : "select"
                    }, {
                        label: "@Language.OUVERTURECIRCUITFAISCEAU_id",
                        name: "ouvertureCircuitFaisceau.id",
                        type : "hidden"
                    }, {
                        label: "@Language.OUVERTURECIRCUITFAISCEAU_idTypeOuvertureCircuitFaisceauListe",
                        name: "ouvertureCircuitFaisceau.idTypeOuvertureCircuitFaisceauListe",
                        type : "select"
                    }, {
                        label: "@Language.INSERT_longueur",
                        name: "insert.longueur"
                    },{
                        label: "@Language.INSERT_idEpaisseurInsertListe",
                        name: "insert.idEpaisseurInsertListe",
                        type : "select"
                    },{
                        label: "@Language.INSERT_idMateriauInsertListe",
                        name: "insert.idMateriauInsertListe",
                        type : "select"
                    },{
                        label: "@Language.INSERT_idFournisseurInsertListe",
                        name: "insert.idFournisseurInsertListe",
                        type : "select"
                    },{
                        label: "@Language.INSERT_referencePlanApprovisionnement",
                        name: "insert.referencePlanApprovisionnement"
                    },{
                        label: "@Language.INSERT_remarques",
                        name: "insert.remarques"
                    }
                ],

                formOptions: {
                    inline: {
                        onBlur: 'submit'
                    }
                }
            });


        $('#insertTable').on('click', 'tbody td:not(:first-child)', function (e) {
            insertEditor.inline(this, {
                submit: 'allIfChanged'
            });
        });

Thanks

Florian

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi Florian,

    I'm sorry no, this isn't currently possible in Editor. Each row has a unique id, which is common to that whole row.

    The only thing I can think of would be to have a different Editor instance for each field, each of which would point at a different property for the id you want to edit (idSrc).

    Allan

  • FrChFGoFrChFGo Posts: 22Questions: 5Answers: 0
    edited April 2018

    Hi Allan

    Finaly, we will try to merge the id value with the name of the field (separate with __) , and extract it in the function who update my database

    would you like a feedback?

This discussion has been closed.