datatables-bundle icon indicating copy to clipboard operation
datatables-bundle copied to clipboard

Update DataTable.php

Open jmons54 opened this issue 3 years ago • 9 comments

Add label to columns in getInitialResponse

jmons54 avatar Jul 24 '22 11:07 jmons54

I didn't see label in columns API : https://datatables.net/reference/option/columns. Maybe title ?

maxhelias avatar Jul 25 '22 07:07 maxhelias

I don't think this will fix anything, as hinted by @maxhelias?

curry684 avatar Aug 10 '22 09:08 curry684

I didn't see label in columns API : https://datatables.net/reference/option/columns. Maybe title ?

https://github.com/omines/datatables-bundle/blob/master/src/Column/AbstractColumn.php#L156

jmons54 avatar Aug 12 '22 13:08 jmons54

I didn't see label in columns API : datatables.net/reference/option/columns. Maybe title ?

https://github.com/omines/datatables-bundle/blob/master/src/Column/AbstractColumn.php#L156

https://datatables.net/reference/option/columns

maxhelias avatar Aug 12 '22 15:08 maxhelias

Since I'm not aware of any bugs with column labels: what is currently broken and what does this fix do about it?

I just want to doublecheck why we should merge this, no issues with the change itself if it's needed.

curry684 avatar Aug 18 '22 08:08 curry684

Since I'm not aware of any bugs with column labels: what is currently broken and what does this fix do about it?

I just want to doublecheck why we should merge this, no issues with the change itself if it's needed.

It's not a bug but we need it to render the datatables with vueJS without jQuery

jmons54 avatar Aug 18 '22 08:08 jmons54

Ok so you're kinda abusing our public API and request a change in it to support a case outside of the scope of the project? 😉

For this case I would recommend staying inside the bounds of the bundle, and use DataTable->setTemplate to override our default HTML template - it has full access to all column configuration and allows you to prepare an HTML section with the column data as JSON which you can then further process as static data with Vue or React.

For reference this is the default template: https://github.com/omines/datatables-bundle/blob/master/src/Resources/views/datatable_html.html.twig

curry684 avatar Aug 18 '22 11:08 curry684

I want use this bundle as API without template twig, for this I need the label data.

jmons54 avatar Aug 30 '22 15:08 jmons54

I understand the use case, I'm just not comfortable with 'weighing down' the bundle's internal API for everyone based, on an unsupported scenario used by few (likely 'one').

I'm more open to solving this request with for example events or abstraction mechanisms. Technically, you can already do what you want, as the getInitialResponse method is protected you can just override it in a VueDataTable extends DataTable. It's not entirely pretty, granted, but it'll allow you to do more customization that you'll likely need.

curry684 avatar Aug 30 '22 15:08 curry684

Stale pull request message

github-actions[bot] avatar Nov 18 '22 22:11 github-actions[bot]