Skip to content

Commit

Permalink
feat: add nameCompositeEditor override to be used by Composite Editor
Browse files Browse the repository at this point in the history
- nameCompositeEditor allows to pass an alternative column title name that could be longer since we have more room to display each title name.
  • Loading branch information
ghiscoding committed Jan 12, 2021
1 parent b634902 commit fcdb2e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
10 changes: 8 additions & 2 deletions packages/common/src/interfaces/column.interface.ts
Expand Up @@ -170,12 +170,18 @@ export interface Column<T = any> {
/** Minimum Width of the column in pixels (number only). */
minWidth?: number;

/** Field Name to be displayed in the Grid (UI) */
/** Column Title Name to be displayed in the Grid (UI) */
name?: string;

/** Field Name translation key that can be used by the translate Service (i18n) to display the text for each column header title */
/** Column Title Name that could be used by the Composite Editor Modal, it has precedence over the column "name" property. */
nameCompositeEditor?: string;

/** Column Title Name translation key that can be used by the translate Service (i18n) to display the text for each column header title */
nameKey?: string;

/** Column Title Name translation key that could be used by the Composite Editor Modal, it has precedence over the column "name" property. */
nameCompositeEditorKey?: string;

/** an event that can be used for executing an action before the cell becomes editable (that event happens before the "onCellChange" event) */
onBeforeEditCell?: (e: SlickEventData, args: OnEventArgs) => void;

Expand Down
Expand Up @@ -614,12 +614,13 @@ export class SlickCompositeEditorComponent implements ExternalResource {
*/
private getColumnLabel(columnDef: Column): string {
const columnGroupSeparator = this.gridOptions.columnGroupSeparator || ' - ';
let columnName = columnDef.name || '';
let columnName = columnDef.nameCompositeEditor || columnDef.name || '';
let columnGroup = columnDef.columnGroup || '';

if (this.gridOptions.enableTranslate && this.translaterService) {
if (columnDef.nameKey) {
columnName = this.translaterService.translate(columnDef.nameKey);
const translationKey = columnDef.nameCompositeEditorKey || columnDef.nameKey;
if (translationKey) {
columnName = this.translaterService.translate(translationKey);
}
if (columnDef.columnGroupKey && this.translaterService?.translate) {
columnGroup = this.translaterService.translate(columnDef.columnGroupKey);
Expand Down
Binary file not shown.

0 comments on commit fcdb2e9

Please sign in to comment.