-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combining Quasar and ag-Grid for CRUD? #50
Comments
Could you please take a look at https://justpy.io/grids_tutorial/database/ ? |
Not sure if you are wanting inline editing or a button click event. For a button click event this is what we had to do. Basically on cell click it prints the column id assuming there is an ID column:
Hope this helps, and if you come up with a better way I would be interested in seeing it. Credit for this goes to: https://github.com/johnrtipton |
Hi @elimintz @knoxvilledatabase Thanks for the prompt responses. I did miss the the SQLite Chinook example on my first pass. I see now this includes multiple tables and some Quasar. This is really great. If we modify the example slightly to make the grid inline editable
Is there a nice way to push the edits back into the tables dataframe? Or indeed add/remove rows? On the example I altered If this is too much work I understand if you choose not to respond. Maybe my half day with JustPy has made me lazy as https://medium.com/ag-grid/building-a-crud-application-with-ag-grid-part-4-3189034df922 sure looks complicated in comparison. I think I can probably use https://stackoverflow.com/questions/52188446/pandas-to-sql-to-update-unique-values-in-db or similar from there as replacing the whole table doesn't seem wise. I am more comfortable with SQL than Python. Any insight is appreciated. |
If you're familiar with Django, one option is to use the django orm with justpy:
Import your django models: Then you can interact with the django orm from the grid:
|
Below please find a simple example in which you use the grid's cellValueChanged event to capture changes from edit. In the example below when a cell changes the event handler cell_changed is called. In the example the values in msg are printed but that is the place where you would update the server side data repository. Let me know if this is what you are looking for. I will work on a more complete CRUD example.
|
This is helpful. Thanks for the assistance. You may have gathered I don't consider myself much of a developer, and more of an all-rounder. Your paragraph Hopefully, JustPy will enable teaching web development in introductory Python courses by reducing the complexity of web development. makes real sense to me. |
I discovered this library today and have been enjoying the ag-Grid examples.
One can use pandas with SQL queries and in turn use JustPy to show these dataframes as tables. This is hugely useful given the small amount of code required and my programming abilities.
I note that I can
grid.options.columnDefs[1].editable = True
(here for column 1) to allow the table rows to be edited in place. Is it possible to pass these updates back into the dataframe?More generally I am in need of a CRUD application which can allow end users to edit various database tables.
I thought perhaps the QButtons example could be modified such that each button represented a DB table but I am unsure if Quasar and ag-Grid can be combined in such a way. As best I can tell ag-Grid is focussed on presenting a single table. Perhaps QTabs where each tab reflects a DB table? I note you mention QTabPanels is not working.
Any advice on how to approach this with JustPy would be very welcome.
Many thanks.
The text was updated successfully, but these errors were encountered: