Skip to content

Commit

Permalink
add getKeyByCardIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
pomahtri committed Dec 10, 2024
1 parent d8e67e1 commit f5bcb63
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { DataRow } from '@ts/grids/new/grid_core/columns_controller/types';
import { DataController } from '@ts/grids/new/grid_core/data_controller';
import type { Constructor } from '@ts/grids/new/grid_core/types';

import type { Key } from '../../grid_core/data_controller/types';
import type { CardViewBase } from '../widget';
import * as cardModule from './content/card/card';
import { ContentView } from './view';
Expand Down Expand Up @@ -43,16 +44,20 @@ export function PublicMethods<T extends Constructor<CardViewBase>>(GridCore: T)
return getPublicElement(card);
}

public getCardIndexByKey(key: unknown): number {
public getVisibleCards(): DataRow[] {
const contentView = this.diContext.get(ContentView);
return contentView.items.unreactive_get();
}

public getCardIndexByKey(key: Key): number {
const contentView = this.diContext.get(ContentView);
const cards = contentView.items.unreactive_get();

return cards.findIndex((card) => card.key === key);
}

public getVisibleCards(): DataRow[] {
const contentView = this.diContext.get(ContentView);
return contentView.items.unreactive_get();
public getKeyByCardIndex(cardIndex: number): Key {
return this.getVisibleCards()[cardIndex]?.key;
}
};
}

0 comments on commit f5bcb63

Please sign in to comment.