one to many join can not see the name filed

one to many join can not see the name filed

xulunwuxulunwu Posts: 8Questions: 3Answers: 0

There is a issue not showing on table. If I change the { data: "ministry", render: "[, ].ministryname" } to { data: "ministry", render: "[, ].id" }, I can see the id value. But I use ministryname that can not show the value of ministryname.

the follow link is my website: http://member.bolkh.org.tw/system/group/member.php

server side code

<?php
header("Conten-Type:text/html;charset=utf-8");
/*
 * Example PHP implementation used for the index.html example
 */

// DataTables PHP library
include( "../../php/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate,
    DataTables\Editor\ValidateOptions;

// Build our Editor instance and process the data coming from _POST
//echo $limitdate;

Editor::inst( $db, 'member' )
    ->fields(
        Field::inst( 'member.logdate' )->validator ( 'Validate::notEmpty',array(
                                                        'message'=>"請填寫登錄日期!"
                                            ) ),
        Field::inst( 'member.name' )->validator ( 'Validate::notEmpty',array(
                                                        'message'=>"請填寫姓名!"
                                            ) ),
        Field::inst( 'member.gender' )->validator ( 'Validate::notEmpty',array(
                                                        'message'=>"請填寫性別!"
                                            ) ),
        Field::inst( 'member.cellphone' ),
        Field::inst( 'member.phone' ),
        Field::inst( 'member.birthday' ),
        Field::inst( 'member.email' )->validator ( 'Validate::email',array(
                                                        'required'=>true,
                                                        'message'=>"請填寫正確的email格式!"
                                            ) ),
        Field::inst( 'member.marriage' ),
        Field::inst( 'member.marriagedate'),
        Field::inst( 'member.address' ),
        Field::inst( 'member.education' )->validator ( 'Validate::notEmpty' )
                                   ->options ( Options::inst()
                                                ->table( 'education' )
                                                ->value( 'id' )
                                                ->label( 'eduname' )
                                             ),
        Field::inst( 'member.career' )->validator ( 'Validate::notEmpty' )
                                   ->options ( Options::inst()
                                                ->table( 'career' )
                                                ->value( 'id' )
                                                ->label( 'careername' )
                                             ),
        Field::inst( 'member.churchpastoral' )->validator ( 'Validate::notEmpty' )
                                   ->options ( Options::inst()
                                                ->table( 'churchpastoral' )
                                                ->value( 'id' )
                                                ->label( 'pastoralname' )
                                             ),
        Field::inst( 'member.group' )->validator ( 'Validate::notEmpty' )
                                   ->options ( Options::inst()
                                                ->table( 'groupdata' )
                                                ->value( 'id' )
                                                ->label( 'groupname' )
                                             ),
        Field::inst( 'member.baptized' ),
        Field::inst( 'member.baptizeddate' ),
        Field::inst( 'member.bapchurch' ),
        Field::inst( 'member.bappastor' ),
        /*Field::inst( 'member.ministry' )->validator ( 'Validate::notEmpty' )
                                   ->options ( Options::inst()
                                                ->table( 'ministry' )
                                                ->value( 'id' )
                                                ->label( 'ministryname' )
                                             ),*/
        Field::inst( 'member.identity' ),
        Field::inst( 'member.relation1' ),
        Field::inst( 'member.rname1' ),
        Field::inst( 'member.rgender1' ),
        Field::inst( 'member.rcareer1' ),
        Field::inst( 'member.rbaptized1' ),
        Field::inst( 'careername.careername' ),
        Field::inst( 'educationname.eduname'),
        Field::inst( 'pastoralname.pastoralname' ),
        Field::inst( 'groupname.groupname' )
    )
    ->join(
        Mjoin::inst( 'ministry' )
            ->link( 'member.id', 'attministry.id' )
            ->link( 'ministry.id', 'attministry.ministryid' )
            ->order( 'ministryname asc' )
            ->fields(
                Field::inst( 'id' )
                    ->validator( 'Validate::required' )
                    ->options( Options::inst()
                        ->table( 'ministry' )
                        ->value( 'id' )
                        ->label( 'ministryname' ),
                Field::inst( 'ministryname' ),
                Field::inst( 'sorting' )
            )
    )
        )
    ->leftJoin('education as educationname', 'member.education','=','educationname.id')
    ->leftJoin('career as careername', 'member.career','=','careername.id')
    ->leftJoin('churchpastoral as pastoralname', 'member.churchpastoral','=','pastoralname.id')
    ->leftJoin('groupdata as groupname', 'member.group','=','groupname.id')
    //->leftJoin('ministry as ministryname', 'member.ministry','=','ministryname.id')
    ->debug( true )
    ->process( $_POST )
    ->json();

<?php
>
```
?>


client side code

columns: [
{ data: "member.name" },
{ data: "member.gender" },
{ data: "member.cellphone" },
{ data: "member.phone" },
{ data: "member.birthday" },
{ data: "member.email" },
{ data: "member.marriage" },
{ data: "member.marriagedate" },
{ data: "member.address" },
{ data: "educationname.eduname" },
{ data: "careername.careername" },
{ data: "pastoralname.pastoralname" },
{ data: "groupname.groupname" },
{ data: "member.baptized" },
{ data: "member.baptizeddate" },
{ data: "member.bapchurch" },
{ data: "member.bappastor" },
{ data: "ministry", render: "[, ].ministryname" },
{ data: "member.identity" }
],
```

Answers

This discussion has been closed.