Skip to content

Commit

Permalink
feat: add rowspan implementation (#1307)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Jan 21, 2025
1 parent e3f4892 commit 9be6b78
Show file tree
Hide file tree
Showing 15 changed files with 1,927 additions and 140 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
"@jest/types": "^29.6.3",
"@lerna-lite/cli": "^3.11.0",
"@lerna-lite/publish": "^3.11.0",
"@slickgrid-universal/common": "^5.11.0",
"@slickgrid-universal/common": "^5.12.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.7",
"conventional-changelog-conventionalcommits": "^7.0.2",
"cross-env": "^7.0.3",
"cypress": "^13.17.0",
"cypress": "^14.0.0",
"cypress-real-events": "^1.13.0",
"eslint": "^9.18.0",
"eslint-plugin-cypress": "^4.1.0",
Expand Down
14 changes: 7 additions & 7 deletions packages/aurelia-slickgrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
"@aurelia/runtime": "^2.0.0-beta.22",
"@aurelia/runtime-html": "^2.0.0-beta.22",
"@formkit/tempo": "^0.1.2",
"@slickgrid-universal/common": "~5.11.0",
"@slickgrid-universal/custom-footer-component": "~5.11.0",
"@slickgrid-universal/empty-warning-component": "~5.11.0",
"@slickgrid-universal/event-pub-sub": "~5.10.2",
"@slickgrid-universal/pagination-component": "~5.11.0",
"@slickgrid-universal/row-detail-view-plugin": "~5.11.0",
"@slickgrid-universal/utils": "~5.10.2",
"@slickgrid-universal/common": "~5.12.0",
"@slickgrid-universal/custom-footer-component": "~5.12.0",
"@slickgrid-universal/empty-warning-component": "~5.12.0",
"@slickgrid-universal/event-pub-sub": "~5.12.0",
"@slickgrid-universal/pagination-component": "~5.12.0",
"@slickgrid-universal/row-detail-view-plugin": "~5.12.0",
"@slickgrid-universal/utils": "~5.12.0",
"dequal": "^2.0.3",
"sortablejs": "^1.15.6"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export class AureliaSlickgridCustomElement {

if (!this.customDataView) {
const dataviewInlineFilters = this.gridOptions.dataView && this.gridOptions.dataView.inlineFilters || false;
let dataViewOptions: Partial<DataViewOption> = { inlineFilters: dataviewInlineFilters };
let dataViewOptions: Partial<DataViewOption> = { ...this.gridOptions.dataView, inlineFilters: dataviewInlineFilters };

if (this.gridOptions.draggableGrouping || this.gridOptions.enableGrouping) {
this.groupItemMetadataProvider = new SlickGroupItemMetadataProvider();
Expand Down Expand Up @@ -778,6 +778,7 @@ export class AureliaSlickgridCustomElement {
}
}

// @deprecated @user `dataview.globalItemMetadataProvider.getRowMetadata`
// did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
if (gridOptions?.colspanCallback && dataView?.getItem && dataView?.getItemMetadata) {
dataView.getItemMetadata = (rowNumber: number) => {
Expand Down
18 changes: 9 additions & 9 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
"@fnando/sparkline": "^0.3.10",
"@formkit/tempo": "^0.1.2",
"@popperjs/core": "^2.11.8",
"@slickgrid-universal/common": "^5.11.0",
"@slickgrid-universal/composite-editor-component": "^5.11.0",
"@slickgrid-universal/custom-tooltip-plugin": "^5.11.0",
"@slickgrid-universal/excel-export": "^5.11.0",
"@slickgrid-universal/graphql": "^5.11.0",
"@slickgrid-universal/odata": "^5.11.0",
"@slickgrid-universal/row-detail-view-plugin": "^5.11.0",
"@slickgrid-universal/rxjs-observable": "^5.11.0",
"@slickgrid-universal/text-export": "^5.11.0",
"@slickgrid-universal/common": "^5.12.0",
"@slickgrid-universal/composite-editor-component": "^5.12.0",
"@slickgrid-universal/custom-tooltip-plugin": "^5.12.0",
"@slickgrid-universal/excel-export": "^5.12.0",
"@slickgrid-universal/graphql": "^5.12.0",
"@slickgrid-universal/odata": "^5.12.0",
"@slickgrid-universal/row-detail-view-plugin": "^5.12.0",
"@slickgrid-universal/rxjs-observable": "^5.12.0",
"@slickgrid-universal/text-export": "^5.12.0",
"aurelia": "^2.0.0-beta.22",
"aurelia-slickgrid": "workspace:*",
"bootstrap": "^5.3.3",
Expand Down
10 changes: 7 additions & 3 deletions packages/demo/src/examples/slickgrid/example14.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export class Example14 {
},
externalResources: [new ExcelExportService()],
explicitInitialization: true,
colspanCallback: this.renderDifferentColspan,
dataView: {
globalItemMetadataProvider: {
getRowMetadata: (item: any, row: number) => this.renderDifferentColspan(item, row),
},
},
gridMenu: {
iconButtonContainer: 'preheader' // we can display the grid menu icon in either the preheader or in the column header (default)
},
Expand Down Expand Up @@ -128,8 +132,8 @@ export class Example14 {
* Your callback will always have the "item" argument which you can use to decide on the colspan
* Your return must always be in the form of:: return { columns: {}}
*/
renderDifferentColspan(item: any): ItemMetadata {
if (item.id % 2 === 1) {
renderDifferentColspan(item: any, row: number): ItemMetadata {
if (item.id % 2 === 1 || row % 2 === 1) {
return {
columns: {
duration: {
Expand Down
85 changes: 85 additions & 0 deletions packages/demo/src/examples/slickgrid/example43.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<h2>
Example 43: colspan/rowspan - Employees Timesheets
<span class="float-end">
<a
style="font-size: 18px"
target="_blank"
href="https://github.com/ghiscoding/aurelia-slickgrid/blob/master/packages/demo/src/examples/slickgrid/example43.ts"
>
<span class="mdi mdi-link-variant"></span> code
</a>
</span>
<button
class="ms-1 btn btn-outline-secondary btn-sm btn-icon"
type="button"
data-test="toggle-subtitle"
click.trigger="toggleSubTitle()"
>
<span class="mdi mdi-information-outline" title="Toggle example sub-title details"></span>
</button>
</h2>

<div class="subtitle" hidden.bind="!showSubTitle">
<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>

<button
class="ms-1 btn btn-outline-secondary btn-sm btn-icon"
data-test="goto-up"
click.trigger="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="ms-1 btn btn-outline-secondary btn-sm btn-icon"
data-test="goto-down"
click.trigger="navigateDown()"
title="from an active cell, navigate to cell below"
>
<span class="mdi mdi-chevron-down"></span>
Navigate Down Cell
</button>
<button
class="ms-1 btn btn-outline-secondary btn-sm btn-icon"
data-test="goto-prev"
click.trigger="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="ms-1 btn btn-outline-secondary btn-sm btn-icon"
data-test="goto-next"
click.trigger="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="ms-1 btn btn-outline-secondary btn-sm btn-icon mx-1" click.trigger="toggleEditing()" data-test="toggle-editing">
<span class="mdi mdi-pencil-outline"></span>
<span
>Toggle Editing: <span id="isEditable" class="text-italic">${ isEditable }</span></span
>
</button>

<aurelia-slickgrid
grid-id="grid43"
column-definitions.bind="columnDefinitions"
grid-options.bind="gridOptions"
dataset.bind="dataset"
instances.bind="aureliaGrid">
</aurelia-slickgrid>
30 changes: 30 additions & 0 deletions packages/demo/src/examples/slickgrid/example43.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#grid43 {
--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-cell-active-box-shadow: inset 0 0 0 1px #3ca4ff;

--slick-row-mouse-hover-box-shadow: 0;
--slick-cell-odd-background-color: #fff;
--slick-cell-border-right: 1px solid var(--slick-border-color);
--slick-cell-border-bottom: 0;
--slick-cell-border-top: 1px solid var(--slick-border-color);
--slick-header-filter-row-border-bottom: 1px solid var(--slick-border-color);
--slick-cell-border-left: 0;
--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; */
}
}
Loading

0 comments on commit 9be6b78

Please sign in to comment.