'custom sorting in Ag-grid use Justpy
I wanna custom sorting ag-grid use justpy. But when I add 'comparator' to columnDefs and run code =>> It not run. It notify l.column.getColDef(...).comparator
can anyone help me
import justpy as jp
grid_options = {
'getDataPath': '''function(data) { return data.orgHierarchy; }''',
'treeData': True,
'defaultColDef': {
'filter': True,
'sortable': True,
'resizable': True,
},
'columnDefs': [
{'headerName': "job title", 'field': "jobTitle"},
{'headerName': "employment type",
'field': "employmentType",
'comparator': '''function(valueA, valueB) {
console.log('valuea', valueA)
if (valueA == valueB) return 0;
return (valueA > valueB) ? 1 : -1;
}'''
},
],
'rowData' : [
{'orgHierarchy': ['Erica'], 'jobTitle': "CEO", 'employmentType': "1"},
{'orgHierarchy': ['Erica', 'Malcolm'], 'jobTitle': "VP", 'employmentType': "2"},
{'orgHierarchy': ['Erica', 'Bob'], 'jobTitle': "SVP", 'employmentType': "3"},
{'orgHierarchy': ['Erica', 'Bob', 'jo'], 'jobTitle': "eVP", 'employmentType': "4"}
]
}
def grid_test():
wp = jp.WebPage()
grid = jp.AgGrid(a=wp, options=grid_options)
print(grid)
grid.evaluate = ['getDataPath']
return wp
jp.justpy(grid_test)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|