You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/dash-examples.md
+46-14
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,17 @@
1
1
# Low-code webapp customizations with Dash
2
2
3
-
## Basic usage
3
+
As seen in the [Introduction to Visual Edit's CRUD Python API](https://github.com/dataiku/dss-visual-edit/blob/master/docs/CRUD_example_usage.ipynb), one can use the Visual Edit API to add a data persistence layer to any webapp.
4
4
5
-
This example is based on the tshirt orders dataset from the [Basics 101 course](https://academy.dataiku.com/basics-101) of the Dataiku Academy. We use the plugin's [`dash_tabulator` component](https://github.com/dataiku/dss-visual-edit/blob/master/dash_tabulator/README.md) for the webapp's data table.
5
+
The plugin's Visual Webapp consists of a single data table component. In this guide, we show how to customize the layout of a data editing and validation webapp in Dash, based on such a component. This can be to:
6
+
7
+
***Add other components to the layout**. The first section of this guide shows the minimal Dash code to use in order to get the same data table as in the Visual Webapp. This is based on the plugin's [`dash_tabulator` component](https://github.com/dataiku/dss-visual-edit/blob/master/dash_tabulator/README.md). You can then add other components to the Dash layout.
8
+
***Customize the settings of the data table**. `dash_tabulator` is based on the [Tabulator](https://tabulator.info/) JavaScript library. The second section gives an example of how to leverage some of its advanced features by customizing column definitions.
9
+
***Use a different data table component**. The third section shows how to use a different data table component in Dash, such as [AG Grid](https://dash.plotly.com/dash-ag-grid).
10
+
11
+
12
+
## Basic usage of `dash_tabulator`
13
+
14
+
This example is based on the tshirt orders dataset from the [Basics 101 course](https://academy.dataiku.com/basics-101) of the Dataiku Academy.
6
15
7
16
Import classes from dash and from the plugin's library:
8
17
@@ -29,22 +38,25 @@ de = DataEditor.DataEditor(
29
38
)
30
39
```
31
40
32
-
Define the columns to use in the data table. This is an object that tells `dash_tabulator` how to render each column, based on its type.
41
+
Define a function that creates a data table from a `DataEditor` object, which will be called when rendering the layout:
`dash_tabulator` is based on [Tabulator](https://tabulator.info/). You can leverage Tabulator's advanced features by defining columns with custom properties.
75
-
76
86
Here we define a calculated column using the Tabulator `mutator` feature and a Javascript function that implements the calculation to perform (here: adding 2 to the values of the `tshirt_quantity` column). We also demonstrate usage of Tabulator's `headerFilter` and `sorter` features.
77
87
78
88
In the previous webapp example, replace the definition of `columns` with the following:
@@ -98,15 +108,37 @@ columns = [
98
108
"title": "calculated",
99
109
"mutator": javascript.assign(
100
110
"""
101
-
function(value, data){
102
-
return parseInt(data.tshirt_quantity) + 2;
103
-
}
104
-
"""
111
+
function(value, data){
112
+
return parseInt(data.tshirt_quantity) + 2;
113
+
}
114
+
"""
105
115
),
106
116
},
107
117
]
108
118
```
109
119
120
+
### Using AG Grid
121
+
122
+
As a preliminary step, make sure to run `pip install dash-ag-grid`.
123
+
124
+
Replace the `create_data_table` function with the following:
See the [dash_tabulator documentation](https://github.com/dataiku/dss-visual-edit/blob/master/dash_tabulator/README.md) and the [Plugin Developer Documentation](https://github.com/dataiku/dss-visual-edit/blob/master/dss-plugin-visual-edit/README.md) for more ways to customize the webapp.
0 commit comments