ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Make child table ready only when tick check box


#1

My idea is :

  1. Want to make read only row wise. When we (tick) the check box first one make read only field “1st half Accomplished Target” and when we (untick) that row should editable.

i used below code but not working:

frappe.ui.form.on(“Appraisal Work Plan”, “goals_on_form_rendered”, function(frm, grid_row, cdt, cdn){
var grid_row = cur_frm.open_grid_row();
if(frm, cdt, cdn, doc.verified1 === 1){
grid_row.grid_form.fields_dict.accomplished_target.df.read_only= true;
grid_row.grid_form.fields_dict.accomplished_target.refresh();
}
});
verified1 is field name of check button.


#2

Try below.

frappe.ui.form.on("Appraisal Work Plan", "goals_on_form_rendered", function(doc, cdt, cdn){
    let grid_row = cur_frm.open_grid_row();
    if(grid_row.doc.verified == 1){
        //disable edit by fieldname
        grid_row.toggle_editable("accomplished_target", 0);
    }
});

#3

@magic-overflow, thanks for your help. it work to make editable and read only but it work for only that particular person who make enable/disable(tick) the check Box.
In my case, check box enable/disable(tick) is done by Supervisor only not by employee. This code make (read only/disable) in supervisor page only.

check box i made level 1, so only supervisor can see check box.

check box(tick/untick) will use/done by supervisor. When supervisor (tick) the check box, it should make ‘accomplished_target’ read only in employee page And when supervisor (untick) the check box, it should editable in employee page

  1. Below is Supervisor page: it work in supervisor page

BUT
2. below is Employee page: when supervisor (tick) check box, it won’t effect to employee page. its still editable.


#4

I’m not in front of the laptop. Can you assign permission level 1 to employee which be able to read (can see but not write) the verify checkbox? The problem might caused by employee can not access verify checkbox value so condition not applied.


#5

@magic-overflow, thanks a lots, it work fine.