Skip to content

Commit

Permalink
Merge pull request #11 from weseek/fix/moves-to-the-bottom-when-activ…
Browse files Browse the repository at this point in the history
…ated-if-there-are-culumns-with-only-number

fix: Moves to the bottom when activated if there are culumns with only number
  • Loading branch information
miya authored Jan 14, 2024
2 parents df93fa0 + 422a37f commit 26c2bd5
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 8 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"client-entry.tsx": {
"file": "assets/client-entry.9428ab67.js",
"file": "assets/client-entry.fe3f0772.js",
"src": "client-entry.tsx",
"isEntry": true,
"css": [
Expand Down
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>growi-plugin-datatables - mock</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N"
crossorigin="anonymous"
/>
</head>
<body>
<div id="MockTableForCaclMethod"></div>
Expand All @@ -13,5 +18,6 @@
<script type="module" src="/src/mock/MockTableForCalcMethod.tsx"></script>
<script type="module" src="/src/mock/MockTable5Lines.tsx"></script>
<script type="module" src="/src/mock/MockTable50Lines.tsx"></script>
<script type="module" src="/src/mock/MockTableIssue9.tsx"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions src/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export const wrapDataTable = (Table: React.FunctionComponent<any>): React.Functi
calculatedData.forEach(({ row, column, calcResult }) => {
api.cell({ row, column }).data(calcResult);
});

// どこかでソート順序が変わるので明示的に元の順序を設定する(issue#9)
(api.order as any).neutral().draw();
};

const displayEnablingDataTableButton = () => {
Expand Down
45 changes: 45 additions & 0 deletions src/mock/MockTableIssue9.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';

import ReactDOM from 'react-dom/client';

import { wrapDataTable } from '../DataTable';

const tableHTML = (
<table className="table table-bordered">
<thead>
<tr>
<th>A</th>
<th>B</th>
</tr>
</thead>
<tbody>
<tr>
<td>a1</td>
<td>ba</td>
</tr>
<tr>
<td>100</td>
<td>bb</td>
</tr>
<tr>
<td>a3</td>
<td>bc</td>
</tr>
<tr>
<td>99</td>
<td>bd</td>
</tr>
<tr>
<td>hoge</td>
<td>moge</td>
</tr>
</tbody>
</table>
);
const DataTables = wrapDataTable(() => tableHTML);

ReactDOM.createRoot(document.getElementById('MockTableForCaclMethod') as HTMLElement).render(
<React.StrictMode>
<DataTables />
</React.StrictMode>,
);

0 comments on commit 26c2bd5

Please sign in to comment.