-
-
Notifications
You must be signed in to change notification settings - Fork 844
Description
First Check
- I added a very descriptive title here.
- This is not a Q&A. I am sure something is wrong with NiceGUI or its documentation.
- I used the GitHub search to find a similar issue and came up empty.
Example Code
@ui.page('/datatable_update')
async def datatable_update_test():
columns = [
{
'field': 'product',
'headerName': 'Product Name',
'editable': False,
},
{
'field': 'quantity',
'headerName': 'Quantity',
'editable': True
},
{
'field': 'price',
'headerName': 'Unit Price',
'editable': True
},
{
'field': 'category',
'headerName': 'Category',
'editable': False
},
{
'field': 'in_stock',
'headerName': 'In Stock',
'editable': True
},
{
'field': 'supplier',
'headerName': 'Supplier',
'editable': False
},
{
'field': 'rating',
'headerName': 'Rating',
'editable': True
},
]
sample_data = [
{
'product': 'Laptop',
'quantity': 10,
'price': 1200.00,
'category': 'Electronics',
'in_stock': True,
'supplier': 'TechCorp',
'rating': 4.5
},
{
'product': 'Mouse',
'quantity': 25,
'price': 25.50,
'category': 'Accessories',
'in_stock': True,
'supplier': 'GadgetPro',
'rating': 4.2
},
{
'product': 'Keyboard',
'quantity': 15,
'price': 45.00,
'category': 'Accessories',
'in_stock': False,
'supplier': 'GadgetPro',
'rating': 4.0
},
{
'product': 'Monitor',
'quantity': 8,
'price': 300.00,
'category': 'Electronics',
'in_stock': True,
'supplier': 'DisplayWorld',
'rating': 4.7
},
{
'product': 'Desk Lamp',
'quantity': 20,
'price': 18.99,
'category': 'Furniture',
'in_stock': True,
'supplier': 'HomeEssentials',
'rating': 4.1
},
{
'product': 'Chair',
'quantity': 5,
'price': 85.00,
'category': 'Furniture',
'in_stock': False,
'supplier': 'HomeEssentials',
'rating': 3.9
},
{
'product': 'Webcam',
'quantity': 12,
'price': 60.00,
'category': 'Electronics',
'in_stock': True,
'supplier': 'TechCorp',
'rating': 4.3
},
]
options = {
'columnDefs': columns,
'rowData': sample_data
}
def get_nicegui_version():
from importlib.metadata import version
return version('nicegui')
def update_datatable(e):
current_data = grid.options['rowData']
for i in range(10):
for item in current_data:
item['quantity'] += 1
if get_nicegui_version() != '3.0.3':
grid.update()
ui.button('trigger update', on_click=update_datatable)
grid = ui.aggrid(options=options)
Description
Before version 3, if we updated aggrid options, we would call grid.update()
after making all the changes to the options. Such updates would be smooth on the frontend without any jerking of the grid.
After v3, these updates cause the aggrid frontend to jerk significantly. It's barely noticeable in the above test, but in our app where there are a lot of elements on the page it's VERY noticeable. Still, in the given code you can make out the difference between v3 and earlier. I have added the grid.update()
inside the for loop to test v2, and there's still no jerking.
To be clear: I understand that props now update the frontend immediately, and that we can defer these updates by making a copy of the column definitions dict and changing that first, then assigning the grid.options to it later. That's not the issue. The issue is that whenever we update grid.options, it's not smooth on the frontend.
I'll try to upload a screencap video later.
NiceGUI Version
3.0.3
Python Version
3.13.7
Browser
Chrome
Operating System
Windows
Additional Context
No response