Error: [object HTMLDivElement] using datatables.net-responsive-dt
Error: [object HTMLDivElement] using datatables.net-responsive-dt
Sanket29
Posts: 2Questions: 0Answers: 0
I am getting [object HTMLDivElement] in mobile view when using slots in responsive mode.
Replies
Happy to take a look at a test case showing the issue.
You might need to use the
listHiddenNodes
render.Allan
How to use in React?
This is my current code.
Change
responsive: true
to be:Allan
Hi Allan, I have the same error but when displaying the slots with a Link component, on the desktop screen it is displayed and redirected perfectly, but on the mobile screen the component is not displayed but the ObjectHtmlDivElement error, I am sending you my code, I have used the solution from the previous post but it does not work, in the console it does not detect the renderer property, I hope you can help me, I am new and I am implementing in an inertia-react project
...
const columns = [
{ data: "id" },
{ data: "title" },
{ data: "codigo" },
{ data: "resumen" },
{ data: "precio" },
{ data: "published_at" },
{ data: "id", orderable: false}
];
<DataTable
ajax={route("apiproperty.index")}
columns={columns}
className="display"
scrollX={true}
options={{
select: true,
responsive: true,
}}
slots={{
6: (data) => (
<Link
className="bg-gray-900 text-white px-3 py-2 mx-5"
href={route("property.edit", data)}
>
Edit
</Link>
),
}}
>
<thead>
<tr>
<th>ID</th>
<th>Título</th>
<th>Código</th>
<th>Resumen</th>
<th>Precio</th>
<th>Publicada</th>
<th>Opciones</th>
</tr>
</thead>
</DataTable>
...
Your code above doesn't use the solution given in my previous post in this thread. Try replacing:
With
If that doesn't work for you, then please create a test case showing the issue on StackBltiz, or link to a minimal git repo with instructions on how to build and run it to show the problem.
Allan
Hi Allan, I'm new to React and reviewing the responsive code further, I managed to solve it and provide the solution for someone who is implementing it.
...
options={{
select: true,
responsive: {
details: {
renderer: function(api, rowIdx, columns) {
const datos = api.row(rowIdx).data(); // Obtiene los datos de la fila
console.log("Datos de la fila:", datos); // Verifica los datos recibidos
console.log("datos de columns", columns);
...
Thank you for your attention and I appreciate the great contribution you provide with DataTables-react-net