KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Add Button in DataTable's Server Processing #878

Closed SOFMAN opened this topic on on May 17, 2019 - 3 comments

SOFMAN commented on May 17, 2019

I need to add a button to a DataTables column, but "formatValue" does not work in Server Processing. How can I add a button?

I have the following code `... "columns" => array(

        "codigo_item" => array("label" => "CODIGO ITEM"),
        "nombre_item" => array("label" => "NOMBRE ITEM"),
        "numero_serie" => array("label" => "SERIE"),
        "tipo_doc_mov_serie_item" => array("label" => "TIPO DOCUMENTO"),
        "numero_documento" => array("label" => "NÂș DOCUMENTO"),
        "nombre_bodega" => array("label" => "BODEGA"),
        "disponibilidad_item_serie" => array("label" => "DISPONIBILIDAD"),
        "integridad_item_serie" => array("label" => "INTEGRIDAD"),
        "razon_social_cliente" => array("label" => "CLIENTE"),
        "razon_social_proveedor" => array("label" => "PROVEEDOR"),
        "nombres_usuario" => array("label" => "CREADO POR"),
        "fecha_hora_creacion_ultimo_movimiento" => array("label" => "FECHA CREACION"),
        "serie_item" => array(
            "formatValue" => function ($value) {
                return '<a class="btn btn-primary" href="' . url('mostrarItemsFacturaHoy/' . $value) . '" >Detalle</a>';
            }
        ),

    ),
    "serverSide" => true,

... `

in the view does not show the button

SOFMAN commented on May 20, 2019

Please answer I need help

David Winterburn commented on May 24, 2019

Hi,

If "formatValue" doesn't work for you in this case, please try to pipe through a Map process like this:

...
->pipe(new \koolreport\processes\Map(array(
    "{value}" => function($row) {
        $value = $row["serie_item"];
        $value = '<a class="btn btn-primary" href="' . url('mostrarItemsFacturaHoy/' . $value) . '" >Detalle</a>';
        $row["serie_item"] = $value;
        return $row;
    }
)))
...

Let us know if this works for you or not. Thanks!

SOFMAN commented on May 24, 2019

Thanks, yes, it worked

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None