Hello,
I want to Disable only “Add new row” button from child table but want to keep “Remove” button in child table.
Thnx,
Nishant Jariwala
Hello,
I want to Disable only “Add new row” button from child table but want to keep “Remove” button in child table.
Thnx,
Nishant Jariwala
Thnx for reply @max_morais_dmm.
But if i make child table as readonly then “Remove Row” button also become disable.
i want to make “Remove Row” Button Enable and “Add New Row” Button Disable.
@max_morais_dmm,
i have one doctype for certain criterias and i am fetching all criterias to another doctype’s child table based on condition.
Here i want to do that user can remove criteria from child table but can not add new criterias.
thnx.
@Nishant_Jariwala, do you can remove
the row when the user adds, and show a message from him, something like this!
var added_row = null;
frappe.ui.form.on('DocType', 'table_field_add', function(frm, cdt, cdn){
added_row = [cdt, cdn];
});
frappe.ui.form.on('Child', 'on_form_render', function(frm, cdt, cdn){
if (added_row && added_row.length==2 && added_row[0] == cdt && added_row[1] == cdn){
frappe.model.remove_from_locals(cdt, cdn);
frm.refresh_form('table_field');
frappe.msgprint('Hey Dude, you cant add a new row here!');
added_row = null;
}
});
can u please tell me how u did that
cur_frm.set_df_property(“properties_list”, “read_only”, 1);
properties_list is your childtable field name… its working 100%
You have two options:
set cannot_add_rows
property of the child table to true
as mentioned here
If you have a required field in the child table, set that field readonly. Then,when users try to add a new row, since that field is mandatory but read-only (it’ll not have a value) the validation will not allow them to save the form.
Incase If you want to know how to update property of child table use the code below
frm.fields_dict[‘child_table_fieldname’].grid.update_docfield_property(‘fieldname’,‘read_only’,1)