Hi all,
i wanna hide the Add row button
i made all the child table read only but in vain
this.frm.get_field("items").grid.cannot_add_rows = true;
This would disable the add_row button, although if you expand the row you’d still get a choice to insert above
or insert below
option.
this.frm.get_field("items").grid.only_sortable();
This will disable the add_row as well as the options inside the expanded row.
Try this jQuery hack, which is for the “Delete” button in a child table. It’s the same logic as for the “Add Row” button. Or hide them both!
For the “Add Row” button…
hideTheButtonWrapper = $('*[data-fieldname="transfers"]');
hideTheButtonWrapper .find('.grid-add-row').hide();
… where “transfers” is the name of your child table.
Why you want to remove add row option? Is the table pre-field?
frappe.ui.form.on(“Sales Order”, “onload”,function(frm,cdt, cdn)
{
$(".grid-add-row").hide();
});
i want to select data from time attendance device in this grid , and it is not logic to add row which is not in device
This will hide all of the add rows in the child tables in the document. That’s probably not good for a document with more than one child table, like your example in Sales Order.
cur_frm.set_df_property(“properties_list”, “read_only”, 1);
properties_list is your childtable field name… its working 100% please close this topic and mark as solution
what if to hide whole child table using one command only
Change it to hidden in Customize Form
tried but it doesn’t work, hidden not working for ‘table’ fieldtype
Use the following code to hide “Add row” and “Delete” in a particular child.
onload: function(frm) {
cur_frm.fields_dict[‘child_table_db_name’].grid.wrapper.find(‘.grid-add-row’).hide();
cur_frm.fields_dict[‘child_table_db_name’].grid.wrapper.find(‘.grid-remove-rows’).hide();
}
cur_frm.set_df_property(“properties_list”, “read_only”, 1); use this in the place of “properties_list” write your childtable name
hello this works for me
cur_frm.fields_dict[“(chiltable name)”].$wrapper.find(‘.btn.btn-xs.btn-default.grid-add-row’).addClass(“hidden”);
Hi all, similarly i need to hide Add Mulitple button below the child table…
frm.get_field(field_name).grid.cannot_add_rows = true;
need to refresh_field(field_name)
I got out using this code.If you want to hide add button completely,write code in refresh event.
refresh:function(frm)
{
frm.get_field(“items”).grid.cannot_add_rows = true;
}
-To hide that button depends on a condition add refresh code too.
frm.get_field(“items”).grid.cannot_add_rows = true;
refresh_field(“items”); //items=mychildTable
In js file:
frappe.ui.form.on(‘Doctype Name’, {
onload:function(frm){
//cannot able to add rows
frm.set_df_property(‘child_field_name’, ‘cannot_add_rows’, true);
//cannot able to delete rows
frm.set_df_property(‘child_field_name’, ‘cannot_delete_rows’, true);
}
});