Parent / child don't selects the parent Entry

Parent / child don't selects the parent Entry

paintitblackpaintitblack Posts: 60Questions: 20Answers: 0

Hi,

I am using the cool „Parent / child editing with Editor” solution (https://datatables.net/blog/2016-03-25).

Unfortunately, when I create a child entry I have to select the parent entry always manually.

I uploaded a test version at https://editor.datatables.net/examples/api/duplicateButton.html. Feel free for any tests.

When you select a parent entry and then click on “New” (for creating a child entry) you have to select the parent entry. At https://datatables.net/blog/2016-03-25 it’s getting selected automatically.

If necessary I can post my php code as well.

Does anybody know the reason?

Thanks, in advance

Patrick

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769

    I uploaded a test version
    Were you linking to a test case you created? It pulls up the duplicate button example.

    Is the problem that the New button is disabled or that when creating a new entry it fails because a parent row is not selected?

    Probably will need to see your code or better a test case.

    Kevin

  • paintitblackpaintitblack Posts: 60Questions: 20Answers: 0

    Hi,

    sorry for the delayed answer. Unfortunately I posted the wring link. The right one is http://wechselstube.host4free.de/start5.php.


    It is possible to create an entry and a child entry, but while creating a child entry I must select the parent entry manually.

    Do you know what I mean?

    Thanks,

    Patrick

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769

    If I understand correctly you want the ability to create a new child entry and select the corresponding parent entry regardless of the parent row selected. Is this correct?

    Kevin

  • paintitblackpaintitblack Posts: 60Questions: 20Answers: 0

    Unfortunetly no. I want it the otherway round so that I don't have to select the parent entry twice (in the table and then in the form).

    I guess there is a bug in my version and I can't see the reason for it. Do you know what I mean?

    You can try it on http://wechselstube.host4free.de/start5.php to create a child entry. Unfortunetly you have to select the parent entry first in the table and afterthat in the form again.

    I think the selected parentId will not deliverd to the form or something like that.

    Can you take a look?

    Kind regards

    Patrick

  • tangerinetangerine Posts: 3,349Questions: 37Answers: 394

    In the blog example you link to, you select a row from the parent table.
    Then, when creating a child table record, the location appears selected in the Editor form. You do not have to select the parent twice.
    If that's not happening for you then you have an error or errors in your own
    code. Can you not revert to the example code and build up from there?

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769
    Answer ✓

    Great, misunderstood the issue :smile: Makes more sense now.

    You are getting this console error:

    Uncaught TypeError: Cannot read property 'def' of undefined
    

    In this part of the config:

            siteTable.on( 'select', function () {
                    usersTable.button( 0 ).enable();
                    usersTable.ajax.reload();
    
                    usersEditor
                            .field( '_stocks.id' )
                            .def( siteTable.row( { selected: true } ).data().id );
            } );
    

    I don't see _stocks.id in your data. Try changing to .field( 'id' ).

    Kevin

  • paintitblackpaintitblack Posts: 60Questions: 20Answers: 0
    edited March 2017

    Hi Kevin,

    this was th right postion and I changed the field value into "_stocks_fees.stock_id" and than it worked pretty good.

    usersEditor
    .field( '_stocks_fees.stock_id' )
    .def( siteTable.row( { selected: true } ).data().id );
    

    Thank you both for your support.

    pib

This discussion has been closed.