Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit c3eefd0

Browse files
committed
feat(typing): add missing item metadata interface
1 parent 1fe958c commit c3eefd0

File tree

6 files changed

+56
-7
lines changed

6 files changed

+56
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"umdModuleIds": {
9090
"@ngx-translate/core": "ngx-translate-core",
9191
"@ngx-translate/core/index": "ngx-translate-core",
92+
"dequal": "dequal",
9293
"dompurify": "dompurify",
9394
"excel-builder-webpacker": "excelBuilderWebpacker",
9495
"flatpickr": "flatpickr",

src/app/examples/grid-colspan.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { AngularGridInstance, Column, FieldType, GridOption } from './../modules/angular-slickgrid';
2+
import { AngularGridInstance, Column, FieldType, GridOption, ItemMetadata } from './../modules/angular-slickgrid';
33

44
@Component({
55
templateUrl: './grid-colspan.component.html',
@@ -118,7 +118,7 @@ export class GridColspanComponent implements OnInit {
118118
* Your callback will always have the "item" argument which you can use to decide on the colspan
119119
* Your return must always be in the form of:: return { columns: {}}
120120
*/
121-
renderDifferentColspan(item: any) {
121+
renderDifferentColspan(item: any): ItemMetadata {
122122
if (item.id % 2 === 1) {
123123
return {
124124
columns: {

src/app/modules/angular-slickgrid/models/gridOption.interface.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ColumnPicker,
99
ColumnReorderFunction,
1010
ContextMenu,
11+
CustomFooterOption,
1112
DataViewOption,
1213
DraggableGrouping,
1314
EditCommand,
@@ -20,6 +21,7 @@ import {
2021
GridState,
2122
HeaderButton,
2223
HeaderMenu,
24+
ItemMetadata,
2325
Locale,
2426
OperatorType,
2527
OperatorString,
@@ -28,7 +30,6 @@ import {
2830
RowMoveManager,
2931
TreeDataOption,
3032
} from './index';
31-
import { CustomFooterOption } from './customFooterOption.interface';
3233

3334
export interface GridOption {
3435
/** CSS class name used on newly added row */
@@ -109,7 +110,7 @@ export interface GridOption {
109110
createFooterRow?: boolean;
110111

111112
/** A callback function that will be used to define row spanning accross multiple columns */
112-
colspanCallback?: (item: any) => { columns: any };
113+
colspanCallback?: (item: any) => ItemMetadata;
113114

114115
/** Default to false, which leads to create an extra pre-header panel (on top of column header) for column grouping purposes */
115116
createPreHeaderPanel?: boolean;

src/app/modules/angular-slickgrid/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export * from './headerButtonOnCommandArgs.interface';
102102
export * from './headerMenu.interface';
103103
export * from './hideColumnOption.interface';
104104
export * from './htmlElementPosition.interface';
105+
export * from './itemMetadata.interface';
105106
export * from './jQueryUiSliderOption.interface';
106107
export * from './jQueryUiSliderResponse.interface';
107108
export * from './keyCode.enum';
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Editor, Formatter, GroupTotalsFormatter } from './index';
2+
3+
/**
4+
* Provides a powerful way of specifying additional information about a data item that let the grid customize the appearance
5+
* and handling of a particular data item. The method should return null if the item requires no special handling,
6+
* or an object following the ItemMetadata interface
7+
*/
8+
export interface ItemMetadata {
9+
// properties describing metadata related to the item (i.e. grid row) itself
10+
11+
/** One or more (space-separated) CSS classes to be added to the entire row. */
12+
cssClasses?: string;
13+
14+
/** Whether or not any cells in the row can be set as "active". */
15+
focusable?: boolean;
16+
17+
/** A custom group formatter. */
18+
formatter?: GroupTotalsFormatter;
19+
20+
/** Whether or not a row or any cells in it can be selected. */
21+
selectable?: boolean;
22+
23+
/** column-level metadata */
24+
columns?: {
25+
// properties describing metadata related to individual columns
26+
27+
[colIdOrIdx in string | number]: {
28+
/** Number of columns this cell will span. Can also contain "*" to indicate that the cell should span the rest of the row. */
29+
colspan?: number | string | '*';
30+
31+
/** A custom cell editor. */
32+
editor?: Editor | null;
33+
34+
/** Whether or not a cell can be set as "active". */
35+
focusable?: boolean;
36+
37+
/** A custom cell formatter. */
38+
formatter?: Formatter | GroupTotalsFormatter;
39+
40+
/** Whether or not a cell can be selected. */
41+
selectable?: boolean;
42+
}
43+
}
44+
}

src/app/modules/angular-slickgrid/models/slickDataView.interface.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Grouping } from './grouping.interface';
2+
import { ItemMetadata } from './itemMetadata.interface';
23
import { PagingInfo } from './pagingInfo.interface';
34
import { SlickEvent } from './slickEvent.interface';
45
import { SlickGrid } from './slickGrid.interface';
56

67
export interface SlickDataView {
78
// --
8-
// Available Methods
9+
// Slick DataView Available Methods
910

1011
/** Add an item to the DataView */
1112
addItem(item: any): void;
@@ -96,7 +97,7 @@ export interface SlickDataView {
9697
getItemCount(): number;
9798

9899
/** Get item metadata at specific index */
99-
getItemMetadata(index: number): any;
100+
getItemMetadata(index: number): ItemMetadata | null;
100101

101102
/** Get DataView length */
102103
getLength(): number;
@@ -134,7 +135,7 @@ export interface SlickDataView {
134135
/** Set some Grouping */
135136
setGrouping(groupingInfo: Grouping | Grouping[]): void;
136137

137-
/** Set a Filter that: will be used by the DataView */
138+
/** Set a Filter that will be used by the DataView */
138139
// eslint-disable-next-line @typescript-eslint/ban-types
139140
setFilter(filterFn: Function): void;
140141

@@ -144,6 +145,7 @@ export interface SlickDataView {
144145
/** Set Paging Options */
145146
setPagingOptions(args: PagingInfo): void;
146147

148+
/** Set Refresh Hints */
147149
setRefreshHints(hints: any): void;
148150

149151
/** Set extra Filter arguments which will be used by the Filter method */

0 commit comments

Comments
 (0)