0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Grid.js の使い方

Last updated at Posted at 2025-09-02

こちらのサンプルを改造しました。
Usage -> Hello World

image.png

フォルダー構造

$ tree
.
├── index.html
└── src
    └── index.js
index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<link
      href="https://unpkg.com/gridjs/dist/theme/mermaid.min.css"
      rel="stylesheet"
    />
<title>テストコーナー</title>
</head>
<body>
<h2>テストのページ</h2>
<div id="wrapper"></div>
<script src="https://unpkg.com/gridjs/dist/gridjs.umd.js"></script>
<script src="src/index.js"></script>
Sep/02/2025 AM 09:00<br />
</body>
</html>
src/index.js
new gridjs.Grid({
  columns: ["名前", "メール", "電話番号"],
  data: [
    ["鈴木", "suzuki@example.com", "090-2222-3333"],
    ["高橋", "takahashi@gmail.com", "080-1234-4321"],
    ["山本", "yamamoto@gmail.com", "070-4422-0033"],
    ["大谷", "ootani@gmail.com", "090-1876-1233"],
    ["佐々木", "sasaki@gmail.com", "080-2287-8356"],
    ["松井", "matsui@gmail.com", "070-1256-4051"]
  ]
}).render(document.getElementById("wrapper"));

サーバーの起動

http-server

http://127.0.0.1:8081/ に接続

ページネーション

image.png

image.png

pagination を加えます。

src/index.js
new gridjs.Grid({
  columns: ["名前", "メール", "電話番号"],
  pagination: {
    limit: 3
  },
  data: [
    ["鈴木", "suzuki@example.com", "090-2222-3333"],
    ["高橋", "takahashi@gmail.com", "080-1234-4321"],
    ["山本", "yamamoto@gmail.com", "070-4422-0033"],
    ["大谷", "ootani@gmail.com", "090-1876-1233"],
    ["佐々木", "sasaki@gmail.com", "080-2287-8356"],
    ["松井", "matsui@gmail.com", "070-1256-4051"]
  ]
}).render(document.getElementById("wrapper"));
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?