import * as React from 'react'; import { ComponentModeWindow, COMPONENT_MODE_OK } from '../common'; export interface MmuiDefaultTableProps { columns: unknown; // columns must be an object that use same keys as records ex: { name: 'Companies', value: 'Percent' } records: [unknown]; // records should respect columns keys ex: [{name:'MM', value:'100%'}, {name:'MM-RO': value : 75%}] staticUrl: string; tableClassNameList: [string]; mode: string; getColumnHeaderRender?: any; getColumnDataRender?: any; caption?: string; } export interface MmuiDefaultTableState {} export class MmuiDefaultTable< P extends MmuiDefaultTableProps, S extends MmuiDefaultTableState > extends React.Component
{
// css classes to apply to the rendered table
tableClassNameList;
constructor(props) {
super(props);
// css classes to apply to the rendered table
this.tableClassNameList = ['table', 'table-sm', 'mmui-table'];
if (props.tableClassNameList) {
this.tableClassNameList = props.tableClassNameList;
}
//@ts-ignore
this.state = {};
}
getColumnHeaderRender(colKey, index) {
if (this.props.getColumnHeaderRender) {
return this.props.getColumnHeaderRender(colKey, index);
}
const records = this.props.records,
classList: Array
{this.props.columns[colKey]}
);
}
getColumnDataRender(record, colKey, index) {
if (this.props.getColumnDataRender) {
return this.props.getColumnDataRender(record, colKey, index);
}
const value = record[colKey],
classList: Array
{record[colKey]}
);
}
getColumnKeys() {
return Object.keys(this.props.columns);
}
getEmptyRow() {
return (
);
}
renderComponentMode(mode, loadingImage) {
return (
No results found.
{this.getColumnKeys().map((colKey, i) => {
return this.getColumnDataRender(
record,
colKey,
`${index}${i}`
);
})}
));
} else {
rows = this.getEmptyRow();
}
return (
);
}
}
{columnsHeaders}
{rows}