Is there a way to get all the data from an object? (symfony)
Is there a way to get all the data from an object? (symfony)
Hi,
I am using the Symfony DataTable Bundle from Omines to generate my datatable. So I generate my columns using this bundle, and my datatable is based on my Event entity.
Is it possible to recover all the data of this entity? Not just the data from the generated columns?
I need this to use the slug of my event as well as the slug of its category for view/edit/delete buttons in the render, currently I am making an Ajax call but it takes longer to load my data!
My code :
"columnDefs": [
{
"targets": -1,
"data": "category",
"render": function (data, type, row, meta) {
var pathView;
$.ajax({
url : "{{ path('event_search') }}",
async: false,
type : 'GET',
data : 'event_id=' + row.id,
success : function(data, status){
pathView = '{{ path("event_show", {"subcategory": "sc", "slug" : "s"}) }}';
pathView = pathView.replace('sc', data.categorySlug).replace('s', data.slug);
}
});
return '<a class="mr-2" href="' + pathView + '"><i class="ion-ios-eye-outline"></i></a><a class="d-contents mr-2" href="%s"><i class="ion-edit mr-2"></i></a><form style="display: inline-block" action="%s" method="POST" onsubmit="%s"><input type="hidden" name="referer" value="en ligne"><input type="hidden" name="_token" value="%s"><button class="d-contents" type="submit"><i class="ion-android-delete"></i></button></form>';
},
// "defaultContent": "<button>Click!</button>"
}
],
Thank you.
Replies
This thread here explains why it's not a good thing to have ajax within
columns.render
. It would be better to build the table first in the DOM, and then initialise DataTables once it's all loaded.Colin