ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Need to hide delete row button in child table

cannot_add_row : true like this anything for delete the row

refresh(frm){
cur_frm.fields_dict[‘child_table_db_name’].grid.wrapper.find(’.grid-remove-rows’).hide();
}

Thanks for reply @SanRam,
It’s worked…

1 Like

again i hv one pblm,
delete row button hidded but inside delete box shown pls let tell me how to restrict this…

image

any update

Try this,

frappe.ui.form.on(‘Doctype Name’, {
child_table_db_name_on_form_rendered:function(frm, cdt, cdn){
frm.fields_dict[“child_table_db_name”].grid.wrapper.find(’.grid-delete-row’).hide();
frm.fields_dict[“child_table_db_name”].grid.wrapper.find(’.grid-duplicate-row’).hide();
frm.fields_dict[“child_table_db_name”].grid.wrapper.find(’.grid-move-row’).hide();
frm.fields_dict[“child_table_db_name”].grid.wrapper.find(’.grid-append-row’).hide();
frm.fields_dict[“child_table_db_name”].grid.wrapper.find(’.grid-insert-row-below’).hide();
frm.fields_dict[“child_table_db_name”].grid.wrapper.find(’.grid-insert-row’).hide();
}
})

i tried sales order here on_form_rendered funtion not work…pls refer below
var child_docname = “items”
var child_doctype = “Sales Order Detail”
frm.data = [];

			const dialog = new frappe.ui.Dialog({
			title: __("Sales Order Detail"),
			fields: [

// {fieldtype:‘Section Break’, label: __(‘Items’)},
{
fieldname: “trans_items”,
fieldtype: “Table”,
cannot_add_rows: true,
in_place_edit: true,
data: frm.data,
label: __(’’),
get_data: () => {
return frm.data;
},
fields: [{
fieldtype:‘Data’,
fieldname:“docname”,
hidden: 1,
}, {
“fieldtype”:‘Link’,
“fieldname”:‘item_code’,
“options”: ‘Item’,
“in_list_view”: 1,
“read_only”: 1,
// disabled: 0,
label: __(‘Item Code’)
}, {
fieldtype:‘Float’,
fieldname:“qty”,
default: 0,
read_only: 0,
in_list_view: 1,
label: __(‘Qty’)
}, {
fieldtype:‘Currency’,
fieldname:“rate”,
default: 0,
in_list_view: 1,
read_only: 0 ,
label: __(‘Rate’)
}]
},
],
// toggle: function(show){
// this.item_code =
primary_action: function() {
var me = this;
const trans_items = this.get_values()[“trans_items”];
frappe.call({
method: ‘erpnext.controllers.accounts_controller.update_child_qty_rate’,
freeze: true,
args: {
‘parent_doctype’: frm.doc.doctype,
‘trans_items’: trans_items,
‘parent_doctype_name’: frm.doc.name,
‘child_docname’: child_docname
},
callback: function() {
frm.reload_doc();
}
});
this.hide();
refresh_field(“trans_items”);
},
primary_action_label: __(‘Update’)
});
frm.doc[child_docname].forEach(d => {
dialog.fields_dict.trans_items.df.data.push({
“docname”: d.name,
“name”: d.name,
“item_code”: d.item_code,
“qty”: d.qty,
“rate”: d.rate,
});

			frm.data = dialog.fields_dict.trans_items.df.data;
	dialog.fields_dict['trans_items'].grid.wrapper.find('.grid-insert-row-below').hide();

pls tell me here how to use on_form_rendered trigger funtion?

frappe.ui.form.on(‘Sales Order’, {
items_on_form_rendered:function(frm, cdt, cdn){
frm.fields_dict[“items”].grid.wrapper.find(’.grid-delete-row’).hide();
}
})

sales order dotype have items table it’s allow the above trigger but i need this trigger trans_items table…the above trigger not work this table via
const dialog = new frappe.ui.Dialog({
title: __(“Sales Order Detail”),
fields: [
// {fieldtype:‘Section Break’, label: __(‘Items’)},
{
fieldname: “trans_items”,
fieldtype: “Table”,
cannot_add_rows: true,
in_place_edit: true,
data: frm.data,
label: __(’’),
get_data: () => {
return frm.data;
},

this trans_items table shown while click on update items button via dialog box
clipboard-image-edited%20(1)

This Code works 100%, it hide the delete button on child table before and after opening child table row

frappe.ui.form.on('Sales Order', {
    refresh(frm) {
        // your code here
        $('*[data-fieldname="items"]').find('.grid-remove-rows').hide();
    },
    
});

frappe.ui.form.on('Sales Order Item', {
	refresh(frm) {
		// your code here
		
	},
	
    form_render(frm, cdt, cdn){
        frm.fields_dict.items.grid.wrapper.find('.grid-delete-row').hide();
        frm.fields_dict.items.grid.wrapper.find('.grid-duplicate-row').hide();
        frm.fields_dict.items.grid.wrapper.find('.grid-move-row').hide();
        frm.fields_dict.items.grid.wrapper.find('.grid-append-row').hide();
        frm.fields_dict.items.grid.wrapper.find('.grid-insert-row-below').hide();
        frm.fields_dict.items.grid.wrapper.find('.grid-insert-row').hide();
    }
});

Thanks lot Elius

@Jecintha :handshake::handshake: