Hi everyone,
I am trying to use frappe datatable inside a custom html block :
html code
<!DOCTYPE html>
<div class="datatable"></div>
javascript code
let elt = root_element.querySelector(".datatable");
let datatable = new frappe.DataTable(elt, {
columns: ['A', 'B', 'C'],
data: [
['1', '2', '3']
]
});
That is what I get
Would have someone any idea ?
gmeunier:
let elt = root_element.querySelector(".datatable");
let datatable = new frappe.DataTable(elt, {
columns: ['A', 'B', 'C'],
data: [
['1', '2', '3']
]
});
hello getting any solution on above datatable in custom html block
Hi Kaushalk,
unfortunately not.
However I did not test it recently.
Bets regards,
Gerald
Abdeali
September 25, 2024, 5:20pm
4
What problem are you facing?
The same as @gmeunier or something else?
Abdeali
September 25, 2024, 5:25pm
5
Try This Code
const datatable_element = root_element.find(".datatable")[0];
const datatable = new frappe.DataTable(datatable_element, {
columns: ['A', 'B', 'C'],
data: [
['1', '2', '3']
]
});
same issue facing
i add that code in js but still data table not showing
Abdeali
September 26, 2024, 5:59am
8
console variables once and share that
Abdeali
September 26, 2024, 6:13am
10
Abdeali:
find
Sorry, Instead of this use querySelector
.
Abdeali:
querySelector
used querySelector
but still table not showing
Hello all,
good to know about frappe.DataTable element, I do not know about it yet…
I have tried these steps:
create html field, “option” = <div class="pojd"></div>
in browser console: let custom_table = $('div.pojd').get(0);
in browser console:
let datatable = new frappe.DataTable(custom_table, {
columns: ['A', 'B', 'C'],
data: [
['1', '2', '3']
]
});
And here is result
Thank you
Jiri Sir
1 Like
Jiri_Sir:
I have tried these steps:
create html field, “option” = <div class="pojd"></div>
in browser console: let custom_table = $('div.pojd').get(0);
in browser console:
let datatable = new frappe.DataTable(custom_table, {
columns: ['A', 'B', 'C'],
data: [
['1', '2', '3']
]
});
try same code but in custom html block data table not show
Abdeali
October 1, 2024, 12:15pm
14
What is your requirement?
You can use Custom Page
if your requirements meet.
Hello,
it is not obviously working in custom block
The element is not found in DOM and root_element.querySelector made the same messy table as mentioned in this topic.
I will take some time and go through it.
Jiri Sir
Hi Everyone,
In fact in my first post, the datatable is working:
You do see the headers, the lines and some formatting appearing.
It is just that the datatable is completely messed up.
Headers and rows are vertical, rows on the left, headers on the right.
And there is a text input field at the bottom
For me it looks more like there is a css conflict linked to css or DOM.
Gerald