36 lines
1.0 KiB
PHP
36 lines
1.0 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Grid.js Row Selection Example</title>
|
|
<!-- Include Grid.js CDN link -->
|
|
<script src="https://cdn.jsdelivr.net/npm/gridjs/dist/gridjs.production.min.js"></script>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridjs/dist/theme/mermaid.min.css" />
|
|
</head>
|
|
<body>
|
|
<div id="grid"></div>
|
|
|
|
<script>
|
|
const grid = new gridjs.Grid({
|
|
columns: ['ID', 'Name', 'Age'],
|
|
data: [
|
|
[1, 'John', 30],
|
|
[2, 'Doe', 25],
|
|
[3, 'Jane', 35]
|
|
],
|
|
plugins: [
|
|
gridjs.plugins.selection({
|
|
enabled: true,
|
|
// Optional: handle selection change
|
|
onChange: (selectedRows, selectedRowIds) => {
|
|
console.log("Selected Rows:", selectedRows);
|
|
console.log("Selected Row IDs:", selectedRowIds);
|
|
}
|
|
})
|
|
]
|
|
}).render(document.getElementById('grid'));
|
|
</script>
|
|
</body>
|
|
</html>
|