perf: set docfields only on doc change

This commit is contained in:
Sagar Vora 2026-02-19 10:24:06 +05:30
parent 9fabfa3054
commit 51c2e9ec89
2 changed files with 7 additions and 3 deletions

View file

@ -574,7 +574,7 @@ export default class Grid {
let grid_row;
if (this.grid_rows[ri] && !append_row) {
grid_row = this.grid_rows[ri];
grid_row.doc = d;
grid_row.update_doc(d);
grid_row.refresh();
} else {
grid_row = new GridRow({

View file

@ -53,6 +53,12 @@ export default class GridRow {
this.wrapper.appendTo(this.parent);
}
update_doc(doc) {
const changed = !this.doc || this.doc !== doc;
this.doc = doc;
if (changed) this.set_docfields();
}
set_docfields() {
if (this.doc && this.parent_df.options) {
this.docfields = frappe.meta.get_docfields(
@ -187,8 +193,6 @@ export default class GridRow {
);
}
refresh() {
this.set_docfields();
if (this.frm && this.doc) {
this.doc = locals[this.doc.doctype][this.doc.name];
}