Using Parent-Child Tables with Join

Using Parent-Child Tables with Join

shatrughanshatrughan Posts: 85Questions: 15Answers: 0

Hi everone..I need Parent Child editing using [https://datatables.net/blog/2019-01-11]

There are two tables : 1) sites[Parent] and 2) users[Child ]

Instead of displaying the total numbers of child rows in parent row, I am in a need to have some mechanism to get the total of a column say Salary of all users(child) of a site. Expanding the parent row should list the individual salary of users alongwith other columns and editing of Salary column must be possible in child rows only. Updating and Deleting of child row(s) be reflected in parent row as a total.

Please help me solve the issue. Thanks

Answers

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

    How far have you got so far? Are you able to link to your page?

    Colin

  • shatrughanshatrughan Posts: 85Questions: 15Answers: 0

    Currently, In order to implement the https://datatables.net/blog/2019-01-11#Parent-table flawlessly, I have created the same tables (sites and users) temporarily. Only one column named 'Salary' has been added to users table. In place of total child rows, I need the sum of Salary columns. The code of https://datatables.net/blog/2019-01-11#Parent-table has been used exactly and nothing different is there to post their links.

    I cann't figure out how to do. Please help as I'm in urgent need of same.

  • shatrughanshatrughan Posts: 85Questions: 15Answers: 0

    There could be a procedure to replace Mjoin in following code with some other join methods to fetch total of child column 'Salary' and be seen in parent row.

    Editor::inst( $db, 'sites' )
    ->fields(
    Field::inst( 'id' )->set( false ),
    Field::inst( 'name' )->validator( 'Validate::notEmpty' )
    )
    ->join(
    Mjoin::inst( 'users' )
    ->link( 'sites.id', 'users.site' )
    ->fields(
    Field::inst( 'id' )
    )
    )

    ->process( $_POST )
    ->json();

    @Colin please suggest ...

  • shatrughanshatrughan Posts: 85Questions: 15Answers: 0

    Waiting for your valuable suggestions...Please guide

This discussion has been closed.