How to have different rendering data between Editor and Datatable ?

How to have different rendering data between Editor and Datatable ?

smassotsmassot Posts: 28Questions: 9Answers: 1

Hello,
I try to find a way for having different rendering between Editor and Datatable view.
In my data, I have some variables which are id's of another data (join), so in Editor I have to use the id's value and in datatable use a string value with a left join. could you help me please ?

for example :
in Datatable : Pending
in Editor : 4 (4 is the Id for Pending in another table)

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 54,703Questions: 1Answers: 8,556 Site admin

    Hi,

    Have you had a look at the join examples, for example this one which show a "label" in the table and Editor edits a different value. If I understand correctly, that sounds like what you are looking for.

    Regards,
    Allan

  • smassotsmassot Posts: 28Questions: 9Answers: 1

    Hi Allan,
    I had to explain that I didn't use your JSON API because I have a sub select to do in my SQL request. So here is an example of data values read :

    {
        "data": [
            {
                "id": "6",
                "date_modif": "26-03-2015",
                "id_etablissement": "2",
                "nom": "PRIEUR",
                "prenom": "Jean",
                "sexe": "H",
                "id_modifieur": null,
                "date_naissance": "07-06-1932",
                "date_entree": "27-08-2013",
                "date_sortie": "17-10-2013",
                "motif_sortie": "57",
                "gir": "1",
                "pmp": "0",
                "demence": "0",
                "cp_provenance": "21200",
                "ville_provenance": "BEAUNE",
                "protection_juridique": "0",
                "aide_sociale": "0",
                "entree_urgence": "0",
                "remarques": null,
                "type_modif": "3",
                "provenance_physique": null,
                "appareillage_marche": null,
                "provenance_geographique": "18",
                "smti": "0",
                "profession_exercee": "21",
                "environnement_domicile": null,
                "situation_avant_entree": null,
                "maintien_domicile": null,
                "personne_origine_entree": null,
                "composante_offre_reelle": null,
                "composante_offre_theorique": null
            }
        ]
    }
    

    as you could see for example 'profession_exercee: 21' where 21 is the ID in profession SQLTable for giving the real name of profession like 'Teacher', I had to store this value after editing, so I have do this :

    {
        "label": "Profession exercée:",
        "name": "profession_exercee",
        "type": "select",
        "ipOpts": [
             {% for profession in parametres.residents.profession_exercee %}
                 {"label": "{{ profession.titre|raw }}", "value": "{{ profession.id }}"},
             {% endfor %}
      ],
         'className': 'full'
    }
    

    and it works perfectly but I tried to have the real name in datatable view and it seems that Editor didn't load from json value but load what we have in datatable view.

    To have the real name in datatable view, I use arrays in my TWIG view like this :

    {{ attribute(data.profession_exercee,data.residents.profession.id) }} // -> Teacher
    (if you don't know twig, it the same as $data[profession_exercee][id] (where id = 21)
    

    Please forgive me for my bad english, hope you could help me in this case.

    Thanks a lot.

  • smassotsmassot Posts: 28Questions: 9Answers: 1
    Answer ✓

    It's ok with your example, I did it !, thanks a lot Allan for your support.

This discussion has been closed.