Showing Object Object instead of showing the button with id in data-id in editor

Showing Object Object instead of showing the button with id in data-id in editor

User123456User123456 Posts: 57Questions: 15Answers: 0
edited August 2017 in Free community support

I was trying to insert the ID of row inside the button with editor, however I'm trying and I cant achieve this.

I tried everything (almost) near:

{ targets: 7,
                 data: "p.id_Publication",
                render: function(data, type, full){
                return '<a data-toggle="modal" data-target="#infoModal" data-id="' + full['p.id_Publication'] + '" id="getPublication" class="blue"><i class="ace-icon fa fa-search-plus bigger-130"></i></a> <a class="red" href="deleteCompany.php?id_Company=' + full + '"><i class="ace-icon fa fa-trash-o bigger-130"></i></a>';
            }

But it doesn return correctly. Or returns undefined, or [object], or an error but not the expected number.

My publication.html

var editor;
    $(document).ready(function() {
        editor = new $.fn.dataTable.Editor( {
            ajax: "lib/publicationProcessing.php",
            table: "#publicationTable",
            fields: [ {
                    label: "Visualizado:",
                    name: "p.status"
                }, {
                    label: "Título da Publicação:",
                    name: "ti.PublicationTitle"
                }, {
                    label: "Tipo de Publicação:",
                    name: "ty.PublicationType"
                }, {
                    label: "Ano:",
                    name: "p.ano"
                }, {
                    label: "Mês:",
                    name: "p.competencia"
                }, {
                    label: "Empresa:",
                    name: "c.razaoSocial"
                }, {
                    label: "Favorecido:",
                    name: "e.nome"
                }, {
                    label: "Botões de Controle:",
                    name: "p.id_Publication"
                }
            ]
        } );

        var table = $('#publicationTable').DataTable( {
            lengthChange: true,
        ajax: {
            url: "lib/publicationProcessing.php",
            type: "POST"
        },
        serverSide: true,
            columns: [
                { data: "p.status",
                render: function ( data, type, row ) {
                    var text = "";
                    if (type == "display") {
                        if (data == "1") {
                            text = "<i class='ace-icon fa fa-circle green'></i>";
                        } else {
                            text = "<i class='ace-icon fa fa-circle red'></i>";
                        }
                        data = text
                    }
                    return data;
                }
            },
                { data: "ti.PublicationTitle" },
                { data: "ty.PublicationType" },
                { data: "p.ano" },
                { data: "p.competencia" },
                { data: "c.razaoSocial" },
                { data: "e.nome" },

                { targets: 7,
                 data: "p.id_Publication",
                render: function(data, type, full){
                return '<a data-toggle="modal" data-target="#infoModal" data-id="' + full['p.id_Publication'] + '" id="getPublication" class="blue"><i class="ace-icon fa fa-search-plus bigger-130"></i></a> <a class="red" href="deleteCompany.php?id_Company=' + full + '"><i class="ace-icon fa fa-trash-o bigger-130"></i></a>';
            }
            }
            ],
            "sScrollX": "100%",
            "sScrollXInner": "115%",
        } );
    } );

processing.php:

<?php
include( "../../php/Datatables.php" );
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;
 
Editor::inst( $db, 'tbl_publication AS p', 'id_Publication' )
    ->fields(
        Field::inst( 'p.status' ),
        Field::inst( 'ti.PublicationTitle' ),
        Field::inst( 'ty.PublicationType'),
        Field::inst( 'p.ano' ),
        Field::inst( 'p.competencia' ),
        Field::inst( 'c.razaoSocial' ),
        Field::inst( 'e.nome'),
        Field::inst( 'p.id_Publication')
    )
    ->leftJoin( 'tbl_ptitle AS ti', 'p.fk_titulo', '=', 'ti.id_PublicationTitle' )
    ->leftJoin( 'tbl_ptype AS ty', 'p.fk_tipo', '=', 'ty.id_PublicationType' )
    ->leftJoin( 'tbl_company AS c', 'p.fk_empresa', '=', 'c.id_Company' )
    ->leftJoin( 'tbl_employee AS e', 'p.fk_empregado', '=', 'e.id_Employee' )
    ->process($_POST)
    ->json();
This discussion has been closed.