forked from ghiscoding/slickgrid-universal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add final rowspan implementation (ghiscoding#1798)
* feat: add final rowspan implementation
- Loading branch information
1 parent
8b02e06
commit 5d0f58e
Showing
30 changed files
with
2,760 additions
and
278 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
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,54 @@ | ||
### Description | ||
You can use Colspan and/or Rowspan by using the DataView Item Metadata Provider, however please note that row spanning is under a flag because of its small perf hit (`rowspan` requires an initial loop through of all row item metadata to map all row span). | ||
|
||
### Demo | ||
|
||
#### Colspan / Rowspan | ||
[Employee Timesheets](https://ghiscoding.github.io/slickgrid-universal/#/example32) / [Demo Component](https://github.com/ghiscoding/slickgrid-universal/blob/master/examples/webpack-demo-vanilla-bundle/src/examples/example32.ts) | ||
|
||
[Large Dataset](https://ghiscoding.github.io/slickgrid-universal/#/example33) / [Demo Component](https://github.com/ghiscoding/slickgrid-universal/blob/master/examples/webpack-demo-vanilla-bundle/src/examples/example33.ts) | ||
|
||
### Basic Usage | ||
|
||
##### Component | ||
|
||
```ts | ||
import { Column, CompositeEditorModalType } from '@slickgrid-universal/common'; | ||
import { SlickCompositeEditorComponent } from '@slickgrid-universal/composite-editor-component'; | ||
|
||
example class MyExample { | ||
gridOptions: GridOption; | ||
columnDefinitions: Column[]; | ||
dataset: any[]; | ||
|
||
// metadata can be dynamic too, it doesn't have to be preset | ||
metadata: ItemMetadata | Record<number, ItemMetadata> = { | ||
0: { | ||
columns: { | ||
1: { rowspan: 2 }, | ||
2: { colspan: 2 }, | ||
10: { colspan: 3, rowspan: 10 }, | ||
13: { colspan: 2 }, | ||
17: { colspan: 2, rowspan: 2 }, | ||
}, | ||
} | ||
}; | ||
|
||
defineGrid() { | ||
this.columnDefinitions = [ /*...*/ ]; | ||
|
||
this.gridOptions.value = { | ||
enableCellNavigation: true, | ||
enableCellRowSpan: true, // required for rowspan to work | ||
dataView: { | ||
globalItemMetadataProvider: { | ||
getRowMetadata: (_item, row) => { | ||
return this.metadata[row]; | ||
}, | ||
}, | ||
}, | ||
rowTopOffsetRenderType: 'top', // rowspan doesn't render well with 'transform', default is 'top' | ||
}; | ||
} | ||
} | ||
``` |
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
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
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
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
73 changes: 73 additions & 0 deletions
73
examples/vite-demo-vanilla-bundle/src/examples/example32.html
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,73 @@ | ||
<h3 class="title is-3"> | ||
Example 32 - colspan/rowspan - Employees Timesheets | ||
<div class="subtitle code-link"> | ||
<span class="is-size-6">see</span> | ||
<a | ||
class="is-size-5" | ||
target="_blank" | ||
href="https://github.com/ghiscoding/slickgrid-universal/blob/master/examples/vite-demo-vanilla-bundle/src/examples/example32.ts" | ||
> | ||
<span class="mdi mdi-link-variant"></span> code | ||
</a> | ||
</div> | ||
</h3> | ||
|
||
<div class="columns"> | ||
<div class="column"> | ||
<p class="italic example-details"> | ||
<b>NOTES</b>: <code>rowspan</code> is an opt-in feature, because of its small perf hit (it needs to loop through all row metadatas to | ||
map all rowspan), and requires the <code>enableCellRowSpan</code> grid option to be enabled to work properly. The | ||
<code>colspan</code>/<code>rowspan</code> are both using DataView item metadata and are both based on row indexes and will | ||
<b>not</b> keep the row in sync with the data. It is really up to you the user to update the metadata logic of how and where the cells | ||
should span when a side effect kicks in. (i.e: Filtering/Sorting/Paging/Column Reorder... will <b>not</b> change/update the spanning | ||
in the grid by itself and that is why they these features are all disabled in this example). Also, column/row freezing (pinning) are | ||
also not supported, or at least not recommended unless you know exactly what you're doing (like in this demo here because we know our | ||
pinning doesn't intersect)! Any freezing column/row that could intersect with a <code>colspan</code>/<code>rowspan</code> | ||
<b>will cause problems</b>. | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<section class="mb-2"> | ||
<div class="row mb-1"> | ||
<button class="button is-small" data-test="goto-up" onclick.delegate="navigateUp()" title="from an active cell, navigate to cell above"> | ||
<span class="mdi mdi-chevron-down mdi-rotate-180"></span> | ||
Navigate Up Cell | ||
</button> | ||
<button | ||
class="button is-small" | ||
data-test="goto-down" | ||
onclick.delegate="navigateDown()" | ||
title="from an active cell, navigate to cell below" | ||
> | ||
<span class="mdi mdi-chevron-down"></span> | ||
Navigate Down Cell | ||
</button> | ||
<button | ||
class="button is-small" | ||
data-test="goto-prev" | ||
onclick.delegate="navigatePrev()" | ||
title="from an active cell, navigate to previous left cell" | ||
> | ||
<span class="mdi mdi-chevron-down mdi-rotate-90"></span> | ||
Navigate to Left Cell | ||
</button> | ||
<button | ||
class="button is-small" | ||
data-test="goto-next" | ||
onclick.delegate="navigateNext()" | ||
title="from an active cell, navigate to next right cell" | ||
> | ||
<span class="mdi mdi-chevron-down mdi-rotate-270"></span> | ||
Navigate to Right Cell | ||
</button> | ||
<button class="button is-small mx-1" onclick.delegate="toggleEditing()" data-test="toggle-editing"> | ||
<span class="mdi mdi-pencil-outline"></span> | ||
<span>Toggle Editing: <span id="isEditable" class="text-italic" textcontent.bind="isEditable">false</span></span> | ||
</button> | ||
</div> | ||
</section> | ||
|
||
<div class="grid-container grid32-container"> | ||
<div class="grid32"></div> | ||
</div> |
28 changes: 28 additions & 0 deletions
28
examples/vite-demo-vanilla-bundle/src/examples/example32.scss
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,28 @@ | ||
.grid32 { | ||
--slick-border-color: #d4d4d4; | ||
// --slick-cell-border-left: 1px solid var(--slick-border-color); | ||
--slick-header-menu-display: none; | ||
--slick-header-column-height: 20px; | ||
--slick-grid-border-color: #d4d4d4; | ||
--slick-row-selected-color: #d4ebfd; | ||
|
||
--slick-row-mouse-hover-box-shadow: 0; | ||
--slick-cell-odd-background-color: #fff; | ||
// --slick-cell-border-top: 0; | ||
--slick-cell-border-right: 1px solid var(--slick-border-color); | ||
--slick-cell-border-bottom: 1px solid var(--slick-border-color); | ||
// --slick-cell-border-left: 1px; | ||
--slick-cell-box-shadow: none; | ||
--slick-row-mouse-hover-color: #fff; | ||
--slick-cell-display: flex; | ||
|
||
.slick-cell.rowspan { | ||
background: white; | ||
z-index: 9; | ||
} | ||
.slick-cell { | ||
display: flex; | ||
align-items: center; | ||
/* justify-content: center; */ | ||
} | ||
} |
Oops, something went wrong.