React
You can find it on stackblitz: stackblitz-guiexpert-react-table-typescript.
Add the following NPM package to your existing React project (run this in your project root directory):
npm install --save @guiexpert/table @guiexpert/react-tableTo add the global guiexpert CSS file in your React project,
you can include the file in the header of the index.html file:
<link href="https://cdn.jsdelivr.net/npm/@guiexpert/table/css/main.css" rel="stylesheet" />You will also find the main.css in the downloaded node module: node_modules/@guiexpert/table/css/main.css.
Create a component and include the guiexpert tag in the template of your component
import { GuiexpertTable } from '@guiexpert/react-table';import { TableFactory, TableOptions } from '@guiexpert/table';
// created once, outside the component: a new model or options object rebuilds the tableconst headerData = [['Column 1', 'Column 2', 'Column 3']]; // array of array!const bodyData = Array.from({ length: 100 }, () => ['This is a very', 'simple', 'demo.']);const tableModel = TableFactory.createTableModel({ headerData, bodyData, overridingColumnWidth: 110 });const tableOptions = new TableOptions();
export const App = () => ( <GuiexpertTable tableModel={tableModel} tableOptions={tableOptions} />);Model or options that depend on props or state: create them with useMemo, so that they only change when their inputs
change.
Be sure, that your div containers expands. Add this CSS rule to your component’s style.
html,body,#root { width: 100%; height: 100%; margin: 0; padding: 0;}