Try ERPNext Buy Support Partners Foundation

Hide row from child table

Hi everyone, I need to Hide a row in earnings (child table) when 2 conditions are true.

When doc is validated and when the name of the component in the child table is ‘AFP1 EMPLEADOR’.

I need to hide for printing or hide it from the DocType (I don’t need to delete it, just hide, because I need it for calculations)

this what I have so far. but I need the method to hide that specific row, and I dont know if “onload” is the specific trigger for it.

frappe.ui.form.on("Salary Slip", {
	onload: function(frm) {
		var tbl = cur_frm.doc.earnings || [];
		var i = tbl.length;
		var estado = cur_frm.doc.status
		while (i--)
		{
			if (estado == 'Paid')
			{
				if(tbl[i].salary_component == 'AFP1 EMPLEADOR')
				{
					cur_frm.doc.earnings[i].hide(); //THIS IS WRONG OBVIOUSLY
				}	
			}
		}
	}
})

Any suggestions?

@josmediaz21

Instead of hiding it on doctype hide it in your custom print format.

Then you can ignore that rows in your calculation. Write the script for your calculation.

1 Like

Try using toggle display. Below is an example:
cur_frm.toggle_display("fieldname", false/true) to hide / unhide field

1 Like

I hide it from the print format.

I need to hide some child table rows on doctype as per login user. Any solution?

You can hide child table rows by user role. Try this in the js

if (frappe.user.has_role(‘Support Team’)) {
frappe.meta.get_docfield(“Name of the Child Table”,“field_name”, cur_frm.doc.name).hidden = 1;
}

It is not working for particular row, it hides the whole column.

I got it, by using the jquery . Its working fine now. :grinning:

frappe.db.get_value(“User”,frappe.session.user,“company”, function(v){
var data = frm.doc.accounts;
data.forEach(function(e){
if (e.company != v.company){
$("[data-idx=’"+e.idx+"’]").hide()
}
})
});

3 Likes