From ddf2587cc7791965a6ccd3eba9909a7120ff1c42 Mon Sep 17 00:00:00 2001 From: Vengadesh Date: Sun, 18 May 2025 06:15:04 +0530 Subject: [PATCH 1/4] feat: Dynamic and configurable child table search bar --- frappe/core/doctype/doctype/doctype.json | 12 +++++++++++- frappe/core/doctype/doctype/doctype.py | 1 + frappe/public/js/frappe/form/grid_row.js | 6 +++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index 5c550637b6..1cc0105b5f 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -33,6 +33,7 @@ "editable_grid", "quick_entry", "grid_page_length", + "grid_search_field_length", "cb01", "track_changes", "track_seen", @@ -697,9 +698,18 @@ "fieldname": "protect_attached_files", "fieldtype": "Check", "label": "Protect Attached Files" + }, + { + "default": "0", + "depends_on": "istable", + "fieldname": "grid_search_field_length", + "fieldtype": "Int", + "label": "Grid Search Field Length", + "non_negative": 1 } ], "grid_page_length": 50, + "grid_search_field_length": 50, "icon": "fa fa-bolt", "idx": 6, "index_web_pages_for_search": 1, @@ -775,7 +785,7 @@ "link_fieldname": "document_type" } ], - "modified": "2025-03-27 18:16:53.286909", + "modified": "2025-05-18 06:10:30.044174", "modified_by": "Administrator", "module": "Core", "name": "DocType", diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index 3939240bfb..b91bbed7e3 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -122,6 +122,7 @@ class DocType(Document): fields: DF.Table[DocField] force_re_route_to_default_view: DF.Check grid_page_length: DF.Int + grid_search_field_length: DF.Int has_web_view: DF.Check hide_toolbar: DF.Check icon: DF.Data | None diff --git a/frappe/public/js/frappe/form/grid_row.js b/frappe/public/js/frappe/form/grid_row.js index ee739ef891..dcd6df33d1 100644 --- a/frappe/public/js/frappe/form/grid_row.js +++ b/frappe/public/js/frappe/form/grid_row.js @@ -852,8 +852,12 @@ export default class GridRow { show_search_row() { // show or remove search columns based on grid rows + let show_length = this.grid?.meta?.grid_search_field_length + ? this.grid.meta.grid_search_field_length > 0 + : 20; this.show_search = - this.show_search && (this.grid?.data?.length >= 20 || this.grid.filter_applied); + this.show_search && + (this.grid?.data?.length >= show_length || this.grid.filter_applied); !this.show_search && this.wrapper.remove(); return this.show_search; } From a770b52f35dac73658beb721c4cbb0b7187f1fec Mon Sep 17 00:00:00 2001 From: Vengadesh Date: Mon, 19 May 2025 08:20:15 +0530 Subject: [PATCH 2/4] fix: modified the condition for fetching the search field length value --- frappe/public/js/frappe/form/grid_row.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frappe/public/js/frappe/form/grid_row.js b/frappe/public/js/frappe/form/grid_row.js index dcd6df33d1..d3830a2272 100644 --- a/frappe/public/js/frappe/form/grid_row.js +++ b/frappe/public/js/frappe/form/grid_row.js @@ -852,9 +852,10 @@ export default class GridRow { show_search_row() { // show or remove search columns based on grid rows - let show_length = this.grid?.meta?.grid_search_field_length - ? this.grid.meta.grid_search_field_length > 0 - : 20; + let show_length = + this.grid?.meta?.grid_search_field_length > 0 + ? this.grid.meta.grid_search_field_length + : 20; this.show_search = this.show_search && (this.grid?.data?.length >= show_length || this.grid.filter_applied); From fae19a802af9db08f24b76c4cc50edbf23a3716b Mon Sep 17 00:00:00 2001 From: Vengadesh Date: Tue, 20 May 2025 19:35:47 +0530 Subject: [PATCH 3/4] fix: Field label changed in doctype json --- frappe/core/doctype/doctype/doctype.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index 1cc0105b5f..df96f9ac72 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -704,7 +704,7 @@ "depends_on": "istable", "fieldname": "grid_search_field_length", "fieldtype": "Int", - "label": "Grid Search Field Length", + "label": "Rows Threshold for Grid Search", "non_negative": 1 } ], From 00e0b1420827c15627f62b63fe2b90784886f839 Mon Sep 17 00:00:00 2001 From: Vengadesh Date: Wed, 21 May 2025 22:06:22 +0530 Subject: [PATCH 4/4] fix: field name changed in doctype json --- frappe/core/doctype/doctype/doctype.json | 7 +++---- frappe/core/doctype/doctype/doctype.py | 2 +- frappe/public/js/frappe/form/grid_row.js | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index df96f9ac72..898fd81011 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -33,7 +33,7 @@ "editable_grid", "quick_entry", "grid_page_length", - "grid_search_field_length", + "rows_threshold_for_grid_search", "cb01", "track_changes", "track_seen", @@ -702,14 +702,13 @@ { "default": "0", "depends_on": "istable", - "fieldname": "grid_search_field_length", + "fieldname": "rows_threshold_for_grid_search", "fieldtype": "Int", "label": "Rows Threshold for Grid Search", "non_negative": 1 } ], "grid_page_length": 50, - "grid_search_field_length": 50, "icon": "fa fa-bolt", "idx": 6, "index_web_pages_for_search": 1, @@ -785,7 +784,7 @@ "link_fieldname": "document_type" } ], - "modified": "2025-05-18 06:10:30.044174", + "modified": "2025-05-21 21:58:59.947374", "modified_by": "Administrator", "module": "Core", "name": "DocType", diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index b91bbed7e3..77a3864860 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -122,7 +122,6 @@ class DocType(Document): fields: DF.Table[DocField] force_re_route_to_default_view: DF.Check grid_page_length: DF.Int - grid_search_field_length: DF.Int has_web_view: DF.Check hide_toolbar: DF.Check icon: DF.Data | None @@ -162,6 +161,7 @@ class DocType(Document): restrict_to_domain: DF.Link | None route: DF.Data | None row_format: DF.Literal["Dynamic", "Compressed"] + rows_threshold_for_grid_search: DF.Int search_fields: DF.Data | None sender_field: DF.Data | None sender_name_field: DF.Data | None diff --git a/frappe/public/js/frappe/form/grid_row.js b/frappe/public/js/frappe/form/grid_row.js index d3830a2272..11fcdaf058 100644 --- a/frappe/public/js/frappe/form/grid_row.js +++ b/frappe/public/js/frappe/form/grid_row.js @@ -853,8 +853,8 @@ export default class GridRow { show_search_row() { // show or remove search columns based on grid rows let show_length = - this.grid?.meta?.grid_search_field_length > 0 - ? this.grid.meta.grid_search_field_length + this.grid?.meta?.rows_threshold_for_grid_search > 0 + ? this.grid.meta.rows_threshold_for_grid_search : 20; this.show_search = this.show_search &&