Add a Child Table Doctype in a anoter Child Table Doctype?

Hello all,

I try to add a new DocType (checked as “is Child Table”) as a field (type Table) into the Sales Order Item Doctype.

The result is : it’s broken.
The detail form of Sales Order Item do not display anymore, error in js part.

I’ve dig into frappe framework and see that’s it’s not currently supported, not explicitly, but just not coded to be possible.
In layout.js and gris.js, it make a mix up on the refresh() method about this new field (set as parent of this new field the grand parent doctype)

My question is, should I propose a PR to avoid this try of design in frappe ?
This kind of control already exists for other not logical design.
This one can be “logic” but not possible for now.

But may be I’ve miss something in my customization ? Didn’t find any clues in documentation, but only not answered post in this forum

Did you manage to make something possible with this use case ?
Like use a HTML field (instead of try the type table field with child table doctype ) and populate it with your own code (with embedded datatable for example)?

1 Like

Really useful, many use cases.

Some tries time ago …

So many changes since v8 vs develop…
Even if this PR was from Rushabh himself it was never merge… Sad

May be one day or another solution ?

Hi @FHenry:

Yes. Seems that no many people showed interest at that time …
I am interested on this feature, I don’t how many people could be interested too.

I’ve made some experimental tentatives … but just for data output …

frappe.ui.form.on("YourChildDoctype", {
	form_render(frm, cdt, cdn) {
        var d = locals[cdt][cdn]
        let html = `
            /* Custom styles for the table */
            .wide-table {
                width: 100%; /* Make table wider */
            .first-column {
                width: 60%; /* First column gets 60% width */
            .text-right {
                text-align: right; /* Align text to the right for numeric columns */
    <div class="container mt-3">
      <table class="table table-bordered table-hover wide-table">
        <!-- Table Head -->
        <thead class="thead-light">
            <th scope="col" class="first-column">Description</th>
            <th scope="col" class="text-right">Qty</th>
            <th scope="col" class="text-right">Amount</th>
        <!-- Table Body -->
            <td>Product 1</td>
            <td class="text-right">5</td>
            <td class="text-right">€50.00</td>
            <td>Service 2</td>
            <td class="text-right">2</td>
            <td class="text-right">€200.00</td>
            <td>Product 3</td>
            <td class="text-right">3</td>
            <td class="text-right">€150.00</td>
            <td>Service 4</td>
            <td class="text-right">1</td>
            <td class="text-right">€100.00</td>
            <td>Product 5</td>
            <td class="text-right">10</td>
            <td class="text-right">€500.00</td>
            <td>Service 6</td>
            <td class="text-right">4</td>
            <td class="text-right">€400.00</td>


Just a try, without fetching data from other doctypes, but is doable.
Hope this helps.


@avc Many thank’s , I’ll give it a try with that, and few happy API call to make update this doctype

1 Like

I have an issue regarding same subject here of your reply if you may.
When I render.html code with jinja from js, it doesn’t work.

Let me explain in detail:
First, I created an html field in my custom DocType of my custom app.

Then I created an html file with simple structure:

Then, render it in js:

It works perfectly:

Now, I want to use jinja, for loop for example:

It broke. And console shows the following error:

Thank you in advance

Are you sure about
for _ in range (1,32) ?
It seems to be another subject by the way.

1 Like

Hi @Omar_M_K_Shehada:


{% for(var i=1, l=32; i<l; i++) { %}
                <td>{{ i }}</td>
                <td class="text-right">5</td>
                <td class="text-right">€50.00</td>
{% } %}

Check this sample on ERPNext code:

Hope this helps.

1 Like

This worked perfectly. Thank you!

1 Like

Yes, yes. It was the issue :sweat_smile:

Hi @Omar_M_K_Shehada @FHenry:

I think that the root problem is that from .js side we need to use John Resig JS microtemplating, and from server side we use Jinja2. Pretty the same thing, but not exactly the same thing :slight_smile: There are some differences in syntax, Jinja is python-like, and JR microtemplating is like javascript …

I was confused with this, and not totally sure about what I am talking about :upside_down_face: :joy: