Skip to content

Commit 7487bb8

Browse files
authored
Merge pull request #176 from anvilistas/fix/unhelpful-sort-error
2 parents 556a6a1 + 3645180 commit 7487bb8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

client_code/Tabulator/_js_tabulator.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,33 @@ def wrapped(data):
170170
171171
""",
172172
)(TabulatorModule.Module)
173+
174+
175+
Function(
176+
"SortModule",
177+
"""
178+
const findSorter = SortModule.prototype.findSorter;
179+
180+
SortModule.prototype.findSorter = function(column) {
181+
try {
182+
return findSorter.call(this, column);
183+
} catch (error) {
184+
var row = this.table.rowManager.activeRows[0],
185+
field, value;
186+
187+
if(row){
188+
row = row.getData();
189+
field = column.getField();
190+
191+
if(field){
192+
value = column.getFieldValue(row);
193+
throw new TypeError(`Cannot determine sorter type for column "${field}": value is not a string, number, boolean, or undefined. Got type: ${typeof value}.
194+
You probably need to set a custom sorter function for this column.`);
195+
}
196+
}
197+
throw error;
198+
}
199+
};
200+
201+
""",
202+
)(TabulatorModule.SortModule)

0 commit comments

Comments
 (0)