Skip to content

Commit dbb4ff5

Browse files
committed
chore: add Row Selection count to demo
1 parent 016af41 commit dbb4ff5

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

examples/vite-demo-vanilla-bundle/src/examples/example21.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ <h3 class="title is-3">
3636
<label for="server-delay">Simulated Server Delay (ms): </label>
3737
<input type="number" id="server-delay" class="is-narrow input is-small" data-test="server-delay" value.bind="serverApiDelay">
3838
</span>
39+
40+
<span class="ml-2">
41+
<label>Selected Rows:</label>
42+
<span textcontent.bind="selectedRowString" data-test="row-selections"></span>
43+
</span>
3944
</div>
4045

4146
<div class="column is-narrow">

examples/vite-demo-vanilla-bundle/src/examples/example21.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default class Example21 {
3232
columnDefinitions!: Column<Item>[];
3333
dataset!: Item[];
3434
sgb!: SlickVanillaGridBundle;
35+
selectedRowString = '';
3536
serverApiDelay = 400;
3637
status = '';
3738
statusClass = '';
@@ -55,6 +56,12 @@ export default class Example21 {
5556

5657
// add all row detail event listeners
5758
this.addRowDetailEventHandlers();
59+
this._bindingEventService.bind(this.gridContainerElm, 'onselectedrowschanged', () => {
60+
this.selectedRowString = this.sgb.slickGrid?.getSelectedRows().join(',') || '';
61+
if (this.selectedRowString.length > 50) {
62+
this.selectedRowString = this.selectedRowString.substring(0, 50) + '...';
63+
}
64+
});
5865
}
5966

6067
dispose() {

test/cypress/e2e/example21.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,12 @@ describe('Example 21 - Row Detail View', () => {
392392
cy.get('.dynamic-cell-detail')
393393
.should('have.length', 0);
394394
});
395+
396+
it('should be able to select any rows, i.e.: row 2 and 4', () => {
397+
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 2}px;"] > .slick-cell:nth(0)`).click();
398+
cy.get(`[style="top: ${GRID_ROW_HEIGHT * 4}px;"] > .slick-cell:nth(0)`).click();
399+
400+
cy.get('[data-test="row-selections"]')
401+
.contains('2,4');
402+
});
395403
});

0 commit comments

Comments
 (0)