Show Mjoin fields as text input

Show Mjoin fields as text input

INTONEINTONE Posts: 153Questions: 58Answers: 6

As I have been checking on the forums, I can see where the join->mjoin shines when it comes to creating option lists and file dile viewing. My use case is a little different. I want to display the mjoin fields as text inputs.

    $data = Editor::inst( $db, 'muscular_skeletal_patient', 'muscular_skeletal_patient_Id' )
    //->debug(true)
    ->fields(
          ......
        )
    ->join(
        Mjoin::inst( 'muscular_skeletal_system' )
            ->link( 'muscular_skeletal_patient.muscular_skeletal_patient_Id', 'muscular_skeletal_patient_link_system.muscular_skeletal_patient_Id' )
            ->link( 'muscular_skeletal_system.muscular_skeletal_system_Id', 'muscular_skeletal_patient_link_system.muscular_skeletal_system_Id' )
            ->fields(
                Field::inst( 'muscular_skeletal_system_Id' )->validator( 'Validate::required' ),
                Field::inst( 'muscular_skeletal_movement_Id' ),
                Field::inst( 'arom_lt' ),
                Field::inst( 'arom_rt' ),
                Field::inst( 'prom_lt' ),
                Field::inst( 'prom_rt' ),
                Field::inst( 'strength_lt' ),
                Field::inst( 'strength_rt' ),
                Field::inst( 'ri_lt' ),
                Field::inst( 'ri_rt' ),
                Field::inst( 'end_feel_lt' ),
                Field::inst( 'end_feel_rt' )
            )
            // ->leftJoin("muscular_skeletal_movement", "muscular_skeletal_movement.muscular_skeletal_movement_Id", "=", "muscular_skeletal_system.muscular_skeletal_movement_Id")

    );

Now on the client-side, I have this:

    editor = new $.fn.dataTable.Editor({
        ajax:
        {
        url: 'includes/server/muscular_skeletal_patient/',
        data: function ( d ) {
            d.CSRFName  = CSRFName;
            d.CSRFToken = CSRFToken;
        }
        },
        table: '#muscular_skeletal_patient',
        fields: [
             {
                name:'muscular_skeletal_system[0].arom_lt'
            },
         ],
    i18n: {
        edit: {
        button: 'View',
        title: '<h3>Muscular Skeletal Patient Details </h3>'
        },
        create: {
        button: 'Create', title: '<h3>Muscular Skeletal Patient Details</h3>' }
        }
    });

The issue is that when the fields are shown, they each include all the values from their respective columns. For example, the arom_lt field shows all its column values, including the array index. As Can be seen below I have two records in the arom_lt column.

arom_lt
20
4

In the arom_lt field in the editor UI, the following value is shown: 2004 even though I am trying to single out each field record using the: name:'muscular_skeletal_system[0].arom_lt'. If I go with the: name:'muscular_skeletal_system[].arom_lt' instead I get 20,4 in the text fields as expected. Is there a way to single out each field index for a mjoin field. I was hoping I could do something like:

{
name:'muscular_skeletal_system[0].arom_lt'
},
{
name:'muscular_skeletal_system[1].arom_lt'
}

and then in the editor UI I would get two fields with 20 and 4 respectively.

Is this possible?

Answers

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

    want to display the mjoin fields as text inputs.

    That's not something Editor currently supports I'm afraid. You could us a custom field type plug-in which would take and give an array, but its not something I've tried with the server-side libraries yet I'm afraid.

    Allan

  • ad824aad824a Posts: 20Questions: 4Answers: 1

    Hi, does this mean there is no real way to have multiple comments associated to a specific row in a table? For instance, having a table of tasks where users can add comments to a task. It would be ideal if the user name and date could be associated with a task.

    If there is an example for this use case I haven't found it, and the previous response in the thread makes me feel like it isn't possible

  • ad824aad824a Posts: 20Questions: 4Answers: 1

    It would be ideal if the user name and date could be associated with a task ~comment~ *

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

    Yes, what you are looking for can be done - we call it parent / child editing.

    Furthermore, with the advent of Editor 2 and its new datatable field type, a nicer way of doing this is with a nested Editor.

    Regards,
    Allan

  • ad824aad824a Posts: 20Questions: 4Answers: 1

    Oh that's perfect! and very cool. Thanks!

This discussion has been closed.