Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add row button on datatable #7

Open
ksonia90 opened this issue Jul 6, 2021 · 0 comments
Open

add row button on datatable #7

ksonia90 opened this issue Jul 6, 2021 · 0 comments

Comments

@ksonia90
Copy link

ksonia90 commented Jul 6, 2021

Hi, any idea on how to add row button based on DB column value? I planned to add it on Action column

so far this is my code:

  1. Controller:
<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\Box;
use Encore\Admin\Widgets\Callout;
use Illuminate\Support\Facades\DB;


class ReportController extends Controller
{
    public function index(Content $content)
    {
        return $content
            ->title($title = 'Report')
            ->row(function (Row $row) {

                $eval = DB::table('evaluations')
                    ->select('admin_users.name', DB::raw('count(evaluations.employee_evaluated) as total_evaluated'),'evaluations.employee_evaluated')
                    ->leftJoin('admin_users', 'admin_users.id', '=', 'evaluations.employee_evaluated')
                    ->groupBy('evaluations.employee_evaluated', 'admin_users.name')
                    ->orderBy('total_evaluated', 'DESC')
                    ->get('total_evaluated', 'admin_users.name');

                $OfficerEvaluatedSummary = view('admin.charts.OfficerEvaluatedSummary', compact('eval'));
                $row->column('12', new Box('Officer Evaluated Summary', $OfficerEvaluatedSummary));
            })->row(function (Row $row) {

                // $bar = view('admin.chartjs.doughnut');
                // $row->column(1/3, new Box('Doughnut chart', $bar));

                // $scatter = view('admin.chartjs.combo-bar-line');
                // $row->column(1/3, new Box('Chart.js Combo Bar Line Chart', $scatter));

                // $bar = view('admin.chartjs.line-stacked');
                // $row->column(1/3, new Box('Chart.js Line Chart - Stacked Area', $bar));

            });
    }
}

  1. Blade
<?php
use Jxlwqq\DataTable\DataTable;
// table
$headers = ['Employee Evaluated', 'Total Evaluation', 'Action'];
$rows = json_decode($eval);

 $style = ['table-bordered', 'table-hover', 'table-striped'];

$options = [
    'paging' => true,
    'lengthChange' => false,
    'searching' => true,
    'ordering' => true,
    'info' => true,
    'autoWidth' => true,
];

 $dataTable = new DataTable($headers, $rows, $style, $options);

echo $dataTable->render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant