-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add a dev page for grid (#2458)
- Loading branch information
1 parent
69c8296
commit 903a6c5
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script type="module"> | ||
import '@vaadin/vaadin-grid/all-imports'; | ||
|
||
const grid = document.querySelector('vaadin-grid'); | ||
|
||
grid.dataProvider = ({ parentItem, page, pageSize }, cb) => { | ||
// Let's have 100 root-level items and 5 items on every child level | ||
const levelSize = parentItem ? 5 : 100; | ||
|
||
const pageItems = [...Array(Math.min(levelSize, pageSize))].map((_, i) => { | ||
const indexInLevel = page * pageSize + i; | ||
|
||
return { | ||
name: `${parentItem ? parentItem.name + '-' : ''}${indexInLevel}`, | ||
children: true | ||
}; | ||
}); | ||
|
||
cb(pageItems, levelSize); | ||
}; | ||
</script> | ||
|
||
<vaadin-grid item-id-path="name"> | ||
<vaadin-grid-selection-column auto-select frozen></vaadin-grid-selection-column> | ||
<vaadin-grid-tree-column frozen path="name" width="200px" flex-shrink="0"></vaadin-grid-tree-column> | ||
<vaadin-grid-column path="name" width="200px" flex-shrink="0"></vaadin-grid-column> | ||
<vaadin-grid-column path="name" width="200px" flex-shrink="0"></vaadin-grid-column> | ||
<vaadin-grid-column path="name" width="200px" flex-shrink="0"></vaadin-grid-column> | ||
</vaadin-grid> | ||
</body> | ||
</html> |