diff --git a/package.json b/package.json index 3296fec6..69ad3ab6 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "pg": "8.7.1", "plotly.js-basic-dist-min": "1.57.1", "react": "16.8.6", + "react-data-table-component": "^7.5.3", "react-dom": "16.8.6", "react-linkify": "^1.0.0-alpha", "react-micro-flyout": "1.0.1", @@ -56,6 +57,7 @@ "react-select": "~3.0.8", "react-splitter-layout": "4.0.0", "sqlite3": "^5.0.2", + "styled-components": "^5.3.6", "td": "0.4.0" }, "devDependencies": { diff --git a/src/renderer/components/QueryResultTable/QueryResultTable.tsx b/src/renderer/components/QueryResultTable/QueryResultTable.tsx index dd7d3d11..4e092fc6 100644 --- a/src/renderer/components/QueryResultTable/QueryResultTable.tsx +++ b/src/renderer/components/QueryResultTable/QueryResultTable.tsx @@ -1,6 +1,7 @@ import React from "react"; import { QueryType } from "../../../lib/Database/Query"; import Linkify from "react-linkify"; +import DataTable from "react-data-table-component"; const MAX_DISPLAY_ROWS_COUNT = 1000; @@ -62,17 +63,28 @@ export default class QueryResultTable extends React.Component { return {cols}; }); - return ( -
- - - {heads} - - {rows} -
- + // Convert column result to datatable + const columns: object[] = []; + query.fields.forEach((el) => { + const item = { + name: el, + selector: (row) => row[el], + sortable: true, + }; + columns.push(item); + }); + + // Convert column result to datatable + const data: object[] = []; + query.rows.forEach((el) => { + const item = {}; + query.fields.forEach((key, idx) => (item[key] = el[idx])); + data.push(item); + }); + + return ( +
+
); }