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

Show or hide column base on condition


#1

Hi I’m trying to hide a certain column base on a condition. I have tried what I saw on the old thread Show or hide columns child table but doesnt work for me.

My code:

frappe.ui.form.on("Purchase Invoice", "onload", function(frm) {
	console.log('>>> ONLOAD <<<');

var df = frappe.meta.get_docfield("Purchase Invoice Item","sales_order", cur_frm.doc.name);
    	df.in_list_view = 0;
		

    	cur_frm.fields_dict.items.grid.set_editable_grid_column_disp("sales_order", false);
    	cur_frm.fields_dict.items.grid.set_editable_grid_column_disp("set_column_disp", false);

    	frm.set_df_property("sales_order", "read_only", 0);
    	frm.set_df_property("sales_order", "in_list_view", 0);

});

#2

Hi @johnskywalker I guess that you can use this

cur_frm.fields_dict.items.grid.fields_map. sales_order.hidden = 1;
cur_frm.refresh_field(“items”);


#3

Dear @johnskywalker

Did you achieved column hiding?