Can't fill second table not even show buttons (add. edit,delete) on page

Can't fill second table not even show buttons (add. edit,delete) on page

Pliachas PaschalisPliachas Paschalis Posts: 62Questions: 12Answers: 1

Link to test case: http://4plus-project-demo-gr.stackstaging.com/mainpage_demoA.php
Debugger code (debug.datatables.net): https://debug.datatables.net/ahuyoq
Error messages shown:
Description of problem: On that page i can not show the buttons of the second table (tblContacts). Am i missing something?
I tried to follow the example i found here "https://editor.datatables.net/examples/advanced/parentChild.html"

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    I might be missing something, but I'm only seeing one table. How do I access the other one?

    Colin

  • Pliachas PaschalisPliachas Paschalis Posts: 62Questions: 12Answers: 1

    I paste the print screen from the site. The second table is below the first one (tblMembers)

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Ah, gotcha. The problem is because you've got an empty element in the ContactsEditor declaration for fields:

                    }, {
                    }, {
    

    Colin

  • Pliachas PaschalisPliachas Paschalis Posts: 62Questions: 12Answers: 1

    Thanks Colin. Thanks for help.
    I am trying to get the id of the Mysql table trying this code

    MembersTable.on('select', function (e) {
                ContactsTable.ajax.reload();
                var pMemberId = MembersTable.row().id();
                var pMemberIdCode = pMemberId.val();
                console.log(pMemberIdCode);
                $idOfMember = MembersTable.rows({ selected: true }).data()[0]['id'];
                console.log('pas');
                console.log($idOfMember);
                console.log(MembersTable.rows({ selected: true }).data()[0]['fUser']);
                ContactsEditor
                    .field('tblContacts.idMember')
                    .def(MembersTable.rows({ selected: true }).data()[0]['id']);
            });
    

    but i can't.
    thanks in advance

  • Pliachas PaschalisPliachas Paschalis Posts: 62Questions: 12Answers: 1

    i corrected the code to this:

    MembersTable.on('select', function (e) {
                ContactsTable.ajax.reload();
                var pMemberId = MembersTable.row().data()[0];
                console.log(pMemberId);
                // var pMemberIdCode = pMemberId.val();
                // console.log(pMemberIdCode);
                $idOfMember = MembersTable.rows({ selected: true }).data()[0]['id'];
                console.log('pas');
                console.log($idOfMember);
                console.log(MembersTable.rows({ selected: true }).data()[0]['fUser']);
                ContactsEditor
                    .field('tblContacts.idMember')
                    .def(MembersTable.rows({ selected: true }).data()[0]['id']);
            });
    

    but with no result. I get undefined in console.

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    Answer ✓
    var pMemberId = MembersTable.row().data()[0];
    

    Because you haven't specified any row identifier to row(), this will only get the data for the first row in the table, not the row that was clicked.

    See this example here - it's showing how to get the data for the row that was clicked,

    Colin

  • Pliachas PaschalisPliachas Paschalis Posts: 62Questions: 12Answers: 1

    Ok i''ll try that and let you know the result. Thanks

  • Pliachas PaschalisPliachas Paschalis Posts: 62Questions: 12Answers: 1

    I used this approach

    MembersTable.row(indexes).id().substring(4)
    

    and finally worked. Thank you

This discussion has been closed.