From c39ae80a135c467741c6a573abaad684fad606b3 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 2 Aug 2023 17:37:00 +1000 Subject: [PATCH] Improve sorting of part column for BOM table (#5386) --- InvenTree/templates/js/translated/bom.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/InvenTree/templates/js/translated/bom.js b/InvenTree/templates/js/translated/bom.js index c8ed1c0541..ebcae2004c 100644 --- a/InvenTree/templates/js/translated/bom.js +++ b/InvenTree/templates/js/translated/bom.js @@ -905,6 +905,18 @@ function loadBomTable(table, options={}) { title: '{% trans "Part" %}', sortable: true, switchable: false, + sorter: function(_valA, _valB, rowA, rowB) { + let name_a = rowA.sub_part_detail.full_name; + let name_b = rowB.sub_part_detail.full_name; + + if (name_a > name_b) { + return 1; + } else if (name_a < name_b) { + return -1; + } else { + return 0; + } + }, formatter: function(value, row) { var url = `/part/${row.sub_part}/`; var html = '';