How to change set_df_property in Child Table Field


I want to make a child table field Required True to Required False.

In Parent table i am using cur_frm.set_df_property(“group”, “hidden”, false); But how can i implement this in child table.


I also need this

I did something similar recently.

Remember this will not effect server side validation. Hope this helps

1 Like


cur_frm.get_field("fields").grid.toggle_reqd("fieldname", true);

thanks @jvermette and @rmehta. But both these solutions change the property for the entire rows.
Cant i change the property for a single row in child table based upon a select or checkbox in the same child row?


I am trying to do the same but instead of making field required, I am making field read only. I tried the method.

cur_frm.get_field(“fields”).grid.toggle_enable(“fieldname”, true);

but got the following error:

Uncaught TypeError: cur_frm.get_field(…).grid.toggle_enable is not a function

I also found the following method :

cur_frm.get_field(“fieldname”).grid.docfields[index].read_only = 1

The above code works and it makes the field read only. But I am not sure that passing the index is right approach to do this. Is their any workaround.

Makarand Bauskar

cur_frm.get_field("fieldname").grid.fieldinfo["child_fieldname"].read_only = 1

if fieldinfo of the child fieldname does not exist, then create an empty dict.


cur_frm.get_field(“fieldname”).grid.fieldinfo[“child_fieldname”] = {}
aslo tried
cur_frm.get_field(“fieldname”).grid.fieldinfo = {“child_fieldname”:{}}

cur_frm.get_field(“fieldname”).grid.fieldinfo[“child_fieldname”].read_only = 1

I tried to set the read_only property to fieldinfo also created the empty dict if fieldname does not exist. But no success.

Makarand Bauskar

Sorry my mistake. Was confusing with get_query

use this:

frappe.meta.get_docfield(this.doctype, fieldname, this.frm.docname).reqd

I have made a helper function, for future releases.


Thank You @rmehta

frappe.meta.get_docfield(this.doctype, fieldname, this.frm.docname).read_only=0

Using this method I am able to set the read_only property of a field on form. But in case of Child Table field or fields within the child table it sets the read only property but the field is read-only even after using the cur_frm.refresh_fields()

Can you specify the exact use case?

@rmehta @makarand_b @BhupeshGupta
how can i change the property for a single row in child table based on some condition in the same child row?

There is no easy way that i know, except if the field is inside the child table and the property you want to change is “hidden”, in which case you can use the “depends on” field.

Maybe you can try playing around with jquery and changing some css of the particular field that you need.

@Nahuel_NsoThank you

1 Like

Hi use below jquery script.

var data = frm.doc.accounts;
if ( != ‘abc’){

Try this solution:

frm.fields_dict.{child_table_field_name}.grid.update_docfield_property(“{field_name}”, “reqd”, 1);