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

Can't render html or edit index column in laravel controller side #3086

Open
conangithub opened this issue Oct 28, 2023 · 1 comment
Open

Comments

@conangithub
Copy link

Summary of problem or feature request

I have index and id columns. I need to modify index column contents to become button link using index value. I need to modify it using render option in blade. Any way to do it in controller?

Code snippet of problem

I need something like this

$result = DB::select('SELECT id, a, b, c FROM my_tables');

$dt = $dataTables->make($result)
            ->addIndexColumn(
               modify to <a href='mylink' class='btn-primary'>index value</a>
            )
            ->rawColumns(['detail'])
            ->toJson();

I can do it in blade like this but I prefer to do it in controller like above.

columns: [
      {data: 'DT_RowIndex', name: 'DT_RowIndex', title: 'No.', render: function(data, type, full, meta) {
          return '<a class="btn-primary" href="mylink">' + data + '</a>';
      }},
]

For additional info, mylink contains value from another column in same table.

System details

  • Operating System : Mac OS Ventura 13.6
  • PHP Version : 8.0
  • Laravel Version : 6.0
  • Laravel-Datatables Version : 9.21.2
@yajra
Copy link
Owner

yajra commented Nov 3, 2023

Tagging for enhancement as this is currently not supported.

The workaround is via column render for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants