Merge branch 'fix/table-widget-create-all-columns' into 'release'

Taking keys from all data points of table to generate columns instead of just first data point of table data.

See merge request theappsmith/internal-tools-client!779
This commit is contained in:
Arpit Mohan 2020-06-26 07:55:45 +00:00
commit f62439445a

View File

@ -185,13 +185,28 @@ export class ReactTableComponent extends React.Component<
});
}
getAllTableColumnKeys = () => {
const tableData: object[] = this.props.tableData;
const columnKeys: string[] = [];
for (let i = 0, tableRowCount = tableData.length; i < tableRowCount; i++) {
const row = tableData[i];
for (const key in row) {
if (!columnKeys.includes(key)) {
columnKeys.push(key);
}
}
}
return columnKeys;
};
getTableColumns = () => {
const tableData: object[] = this.props.tableData;
let columns: ReactTableColumnProps[] = [];
const hiddenColumns: ReactTableColumnProps[] = [];
if (tableData.length) {
const row = tableData[0];
for (const i in row) {
const columnKeys: string[] = this.getAllTableColumnKeys();
for (let index = 0, length = columnKeys.length; index < length; index++) {
const i = columnKeys[index];
const columnName: string =
this.props.columnNameMap && this.props.columnNameMap[i]
? this.props.columnNameMap[i]