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.
lokesh
December 18, 2019, 6:55am
#5
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;
}
lokesh
December 19, 2019, 6:41am
#7
It is not working for particular row, it hides the whole column.
lokesh
December 19, 2019, 7:27am
#8
I got it, by using the jquery . Its working fine now.
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
refresh : function(frm){
var table=frappe.meta.get_docfield(“User”, “email”,frm.doc.name);
table.hidden=1;
frm.refresh_fields();
}
gudiva
April 7, 2022, 4:31am
#10
Greetings,
Following on from this thread, how would I go about hiding a particular row when printing if the value of a field is equal to zero?
For example, in the Sales Order item table, if I have the field Rate set to 0.00 how could I hide the entire row for that item when it comes to printing?
Many thanks in advance.