Unofficial backend utilities for using Material-UI's X-Data-Grid component
Project description
MUI Data Grid
This is an unofficial toolbox to make integrating a Python web application with Material UI's data grid simpler.
Documentation
Requirements
- Python 3.7+
Installation
Pip
python -m pip install -U mui-data-grid
or with extras:
python -m pip install -U mui-data-grid[flask]
Poetry
poetry add mui-data-grid
Usage
Integrations
Flask
#!/usr/bin/env python
# examples/main.py
from flask import Flask, jsonify
from flask.wrappers import Response
from mui.v5.integrations.flask import get_grid_models_from_request
app = Flask(__name__)
FILTER_MODEL_KEY = "filter_model"
SORT_MODEL_KEY = "sort_model[]"
PAGINATION_MODEL_KEY = None # stored inline in the query string, not encoded as an obj
@app.route("/")
def print_sorted_details() -> Response:
# models will return default values if the keys don't exist,
# so you can choose what features you integrate, and when.
models = get_grid_models_from_request(
filter_model_key=FILTER_MODEL_KEY,
pagination_model_key=PAGINATION_MODEL_KEY,
sort_model_key=SORT_MODEL_KEY,
)
return jsonify(
{
# sort_model is a list[GridSortItem]
SORT_MODEL_KEY: [model.dict() for model in models.sort_model],
# filter_model is GridFilterModel
FILTER_MODEL_KEY: models.filter_model.dict(),
# pagination_model is a GridPaginationModel
# providing a consistent interface to pagination parameters
PAGINATION_MODEL_KEY: models.pagination_model,
}
)
if __name__ == "__main__":
app.run()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mui_data_grid-0.2.0.tar.gz
(12.7 kB
view hashes)
Built Distribution
Close
Hashes for mui_data_grid-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a49388835a499b7405e4e09b002bc121f06fc34b28cf26d4437e51b442d7797 |
|
MD5 | 38c853a4a94099774fb53654e1f61984 |
|
BLAKE2b-256 | 85b9a0b077293aa21292e2e6b82ba7b5b21b777cf6c54623f842a19d0358d3e8 |