Skip to main content

2. How to Build a Table

Step-by-step

Drag in components

A typical table page has a filter, table, and pagination. Fusion UI provides these—find them in the left component panel.

image.png

Drag them onto the canvas: Feb-16-2022 16-58-59.gif

Configure components

Select the filter component you dropped and configure it: Feb-14-2022 17-59-47.gif

For array fields you can add/remove items, edit fields, and reorder.

image.png

With that, you can configure a typical filter: Feb-21-2022 18-05-52.gif

Bind data

Low-code pages need dynamic data. Use the source panel on the left to define state and handlers:

image.png

Add sample data to state:

    "companies": [
{ company: 'Test Company1', id: 1, createTime: +new Date() },
{ company: 'Test Company2', id: 2, createTime: +new Date() },
{ company: 'Test Company3', id: 3, createTime: +new Date() },
]

Then bind it to component props:

image.png

image.png

Use an expression:

this.state.companies;

Together with component configuration, you can set up the table body:

image.png

Dynamic requests

Use a lifecycle method to fetch data. Example API: http://rap2api.taobao.org/app/mock/250089/testCompanies

class LowcodeComponent extends Component {
state = {
text: 'outer',
isShowDialog: false,
loading: false,
companies: [
{ company: 'Test Company 1', id: 1, createTime: +new Date() },
{ company: 'Test Company 2', id: 2, createTime: +new Date() },
{ company: 'Test Company 3', id: 3, createTime: +new Date() },
],
};
componentDidMount() {
this.setState({ loading: true });
window
.fetch('http://rap2api.taobao.org/app/mock/250089/testCompanies')
.then((res) => res.json())
.then((companies) => {
this.setState({
companies,
});
})
.catch((err) => console.error(err))
.then(() => {
this.setState({ loading: false });
});
}
}

On componentDidMount, the page requests the API and updates loading and companies.

After save or closing the source panel, the code takes effect:

image.png

Configure slots

Bind loading to the loading indicator:

image.png

Feb-16-2022 20-24-35.gif

After binding visible on Loading to this.state.loading, a slot appears. Drop other components into the slot:

Feb-16-2022 20-27-03.gif

Click Preview (top right) to see the live request:

Feb-16-2022 20-28-36.gif

Column dialog hook

To open a dialog from a table column, first add a dialog: Feb-16-2022 20-32-09.gif

Use the outline tree to show/hide the dialog while editing: Feb-16-2022 20-32-39.gif

Add a data column: Feb-16-2022 20-39-41.gif

Set its action to Dialog: Feb-16-2022 20-40-05.gif

Result: Feb-16-2022 20-42-51.gif

Event callbacks

The previous section bound behavior on a data column. Here we bind the action column. Click Add item under the action buttons: Feb-23-2022 11-58-02.gif

Select the detail button and configure its event callback: Feb-23-2022 12-00-18.gif

In code, define the handler:

onClick_new(e, { rowKey, rowIndex, rowRecord }){
window.Next.Message.show(JSON.stringify({ rowKey, rowIndex, rowRecord }))
}

Save and preview: Feb-23-2022 12-05-25.gif

Study the example schema

The example schema is hosted here: https://mo.m.taobao.com/marquex/lowcode-showcase-table

Import it via the Schema panel (bottom left). image.png