Dear Team,
Kindly suggest, how to 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.
Did you try setting up the Permissions in Role Permission Manager?
But It dint work for child table
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.
Worked
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();
},
});
You can use something like:
frm.get_field("TABLE_NAME").grid.df.cannot_delete_rows = true;
right method is
frm.set_df_property(‘table_field_name’, ‘cannot_delete_rows’, 1);