ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Disable "Remove" Button to stop deletion of child table records

Dear Team,

Kindly suggest, how to Disable “Remove” Button to stop deletion of child table records.

@KanchanChauhan can you help with the solution?

Did you try setting up the Permissions in Role Permission Manager?

But It dint work for child table

@Ram_Gopal_Rao did you find any solution ?

I hope this will help you.

Try this:
$('*[data-fieldname="items"]').find('.grid-remove-rows').hide();

where ‘items’ is your table name in your doctype.

2 Likes

Worked :slight_smile:

Plus you can hide the trash button which comes in child table’s popup window.

[data-fieldname="items"]_on_form_rendered:function(frm, grid_row, cdt, cdn){
	 $(".grid-delete-row").hide()
}

This code works 100% to hide delete button for both before and after opening row on child table

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();
    },
});
1 Like