Skip to content

Commit

Permalink
feat(typing): add missing item metadata interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Mar 30, 2021
1 parent 1fe958c commit c3eefd0
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"umdModuleIds": {
"@ngx-translate/core": "ngx-translate-core",
"@ngx-translate/core/index": "ngx-translate-core",
"dequal": "dequal",
"dompurify": "dompurify",
"excel-builder-webpacker": "excelBuilderWebpacker",
"flatpickr": "flatpickr",
Expand Down
4 changes: 2 additions & 2 deletions src/app/examples/grid-colspan.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { AngularGridInstance, Column, FieldType, GridOption } from './../modules/angular-slickgrid';
import { AngularGridInstance, Column, FieldType, GridOption, ItemMetadata } from './../modules/angular-slickgrid';

@Component({
templateUrl: './grid-colspan.component.html',
Expand Down Expand Up @@ -118,7 +118,7 @@ export class GridColspanComponent implements OnInit {
* 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) {
renderDifferentColspan(item: any): ItemMetadata {
if (item.id % 2 === 1) {
return {
columns: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ColumnPicker,
ColumnReorderFunction,
ContextMenu,
CustomFooterOption,
DataViewOption,
DraggableGrouping,
EditCommand,
Expand All @@ -20,6 +21,7 @@ import {
GridState,
HeaderButton,
HeaderMenu,
ItemMetadata,
Locale,
OperatorType,
OperatorString,
Expand All @@ -28,7 +30,6 @@ import {
RowMoveManager,
TreeDataOption,
} from './index';
import { CustomFooterOption } from './customFooterOption.interface';

export interface GridOption {
/** CSS class name used on newly added row */
Expand Down Expand Up @@ -109,7 +110,7 @@ export interface GridOption {
createFooterRow?: boolean;

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

/** Default to false, which leads to create an extra pre-header panel (on top of column header) for column grouping purposes */
createPreHeaderPanel?: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/app/modules/angular-slickgrid/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export * from './headerButtonOnCommandArgs.interface';
export * from './headerMenu.interface';
export * from './hideColumnOption.interface';
export * from './htmlElementPosition.interface';
export * from './itemMetadata.interface';
export * from './jQueryUiSliderOption.interface';
export * from './jQueryUiSliderResponse.interface';
export * from './keyCode.enum';
Expand Down
44 changes: 44 additions & 0 deletions src/app/modules/angular-slickgrid/models/itemMetadata.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Editor, Formatter, GroupTotalsFormatter } from './index';

/**
* Provides a powerful way of specifying additional information about a data item that let the grid customize the appearance
* and handling of a particular data item. The method should return null if the item requires no special handling,
* or an object following the ItemMetadata interface
*/
export interface ItemMetadata {
// properties describing metadata related to the item (i.e. grid row) itself

/** One or more (space-separated) CSS classes to be added to the entire row. */
cssClasses?: string;

/** Whether or not any cells in the row can be set as "active". */
focusable?: boolean;

/** A custom group formatter. */
formatter?: GroupTotalsFormatter;

/** Whether or not a row or any cells in it can be selected. */
selectable?: boolean;

/** column-level metadata */
columns?: {
// properties describing metadata related to individual columns

[colIdOrIdx in string | number]: {
/** Number of columns this cell will span. Can also contain "*" to indicate that the cell should span the rest of the row. */
colspan?: number | string | '*';

/** A custom cell editor. */
editor?: Editor | null;

/** Whether or not a cell can be set as "active". */
focusable?: boolean;

/** A custom cell formatter. */
formatter?: Formatter | GroupTotalsFormatter;

/** Whether or not a cell can be selected. */
selectable?: boolean;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Grouping } from './grouping.interface';
import { ItemMetadata } from './itemMetadata.interface';
import { PagingInfo } from './pagingInfo.interface';
import { SlickEvent } from './slickEvent.interface';
import { SlickGrid } from './slickGrid.interface';

export interface SlickDataView {
// --
// Available Methods
// Slick DataView Available Methods

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

/** Get item metadata at specific index */
getItemMetadata(index: number): any;
getItemMetadata(index: number): ItemMetadata | null;

/** Get DataView length */
getLength(): number;
Expand Down Expand Up @@ -134,7 +135,7 @@ export interface SlickDataView {
/** Set some Grouping */
setGrouping(groupingInfo: Grouping | Grouping[]): void;

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

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

/** Set Refresh Hints */
setRefreshHints(hints: any): void;

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

0 comments on commit c3eefd0

Please sign in to comment.