How can i implement nested Table's in ERPNext

Dear All,

i wanted to implement, nested TABLE’s in erpnext, could anyone guide me ,

i want to access the “doc” in the following method. but, if you notice we are getting the doc from the this.frm.doc, is there a way to pass the current open table doc in the Grid ?? instead of this.frm.doc

Please help. Thanks.

add_new_row: function(idx, callback, show) {
        if(this.is_editable()) {
           // instead of this.frm.doc, i want to pass the current parent doc.
            var d = wn.model.add_child(this.frm.doc, this.df.options, this.df.fieldname, idx);
            this.frm.script_manager.trigger(this.df.fieldname + "_add", d.doctype, d.name);
            this.refresh();

            if(show) {
                if(idx) {
                    this.wrapper.find("[data-idx='"+idx+"']").data("grid_row")
                        .toggle_view(true, callback);
                } else {
                    this.wrapper.find(".grid-row:last").data("grid_row").toggle_view(true, callback);
                }
            }
            this.frm.script_manager.trigger(this.df.fieldname + "_post_render", d.doctype, d.name);
            return d;
        }
    },
1 Like

If you guys can atleast tell me , how can i pass the current docname to the Grid → wn.ui.form.Grid

i will be able to solve this issue. however i cannot use the this.frm.docname , as it will always give me the FORM docname, but instead i want to know the parent grid docname for the child grid.

I have reached here so far, but my main issue over here is, if i add a new child row for a parent, then it gets added to all the other parent rows as well.

Thanks

Really hard to look at this. Generally nested tables is a bad design.

plus, you are not sharing anything.