Created
April 7, 2015 06:07
-
-
Save rmehta/ff015c3be1f96d7109a3 to your computer and use it in GitHub Desktop.
Frappe Custom Script. Trigger on add row
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frappe.ui.form.on("Z Item", { | |
"set_total": function(frm) { | |
var grand_total = 0; | |
$.each(frm.doc.z_items, function(i, d) { grand_total += d.qty; }); | |
frm.set_value("grand_total", grand_total); | |
}, | |
"z_items_add": function(frm, ) { | |
frm.events.set_total(frm); | |
}, | |
"qty": function(frm) { | |
frm.events.set_total(frm); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sir, I use your script to calculate some total value of one child table. It can trigger the total field when I add row or update "cases" row. However, it can't trigger the total field when I remove(delete) a row. Could you please tell me how to solve this problem. My code is listed below.
frappe.ui.form.on("PI_Sale Item",{
"set_totalcase": function(frm) {
var tocases = 0;
$.each(frm.doc.pisaleitem, function(i, d) {
tocases += d.cases;}
);
frm.set_value("tocases", tocases);
refresh_field("tocases");
},
"cases": function(frm) {
frm.events.set_totalcase(frm);
},
});