From 4008c524013a5090e6b0267567fe438452bf6b7f Mon Sep 17 00:00:00 2001 From: vishakhdesai Date: Mon, 30 Dec 2024 11:39:43 +0530 Subject: [PATCH] fix: update idx and name in table before rendering result rows --- frappe/public/js/frappe/form/grid.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frappe/public/js/frappe/form/grid.js b/frappe/public/js/frappe/form/grid.js index 5f4b90fa91..bbee20f4a2 100644 --- a/frappe/public/js/frappe/form/grid.js +++ b/frappe/public/js/frappe/form/grid.js @@ -126,6 +126,7 @@ export default class Grid { this.setup_add_row(); this.setup_grid_pagination(); + this.update_idx_and_name(); this.custom_buttons = {}; this.grid_buttons = this.wrapper.find(".grid-buttons"); @@ -148,6 +149,17 @@ export default class Grid { } } + update_idx_and_name() { + this.data.forEach((d, ri) => { + if (d.idx === undefined) { + d.idx = ri + 1; + } + if (d.name === undefined) { + d.name = "row " + d.idx; + } + }); + } + set_doc_url() { let unsupported_fieldtypes = frappe.model.no_value_type.filter( (x) => frappe.model.table_fields.indexOf(x) === -1