Generic UI Angular Grid API

Grid API

The grid library provides an api to make changes to the grid components. It also allows to retrieve data handled by the grid.

import { GuiGridComponent, GuiGridApi } from '@generic-ui/ngx-grid';

@Component({
	template: `
	<gui-grid #grid ...></gui-grid>
	`
})
class ExampleComponent implements AfterViewInit {
	
	@ViewChild('grid', { static: true })
	gridComponent: GuiGridComponent;
	
	ngAfterViewInit {
		const api: GuiGridApi = this.gridComponent.api;

		api.selectAll();
	}
}

Modifications

NameDescription
setSource(items: Array<any>): voidSets new source for the grid.
deleteRow(row: GuiSelectedRow): voidDeletes row.
deleteRows(rows: Array<GuiSelectedRow>): voidDeletes an array of rows.
getSelectedRows(): Array<GuiSelectedRow>Returns an array of selected rows.
showLoading(): voidTurns on and shows loading overlay.
hideLoading(): voidHides loading overlay.

Selection

NameDescription
selectAll(): voidSelects all rows.
unselectAll(): voidUnselects all rows.

Viewport

NameDescription
scrollToTop(): voidScrolls grid to the top.
scrollToBottom(): voidScrolls grid to the bottom.
scrollToRowByIndex(index: number): void;Scrolls grid to the target row.

Searching

NameDescription
setSearchingConfig(config: SearchConfig): voidSets searching config.
search(phrase: string): voidSets search phrase.
clearSearchPhrase(): voidClears search phrase.

Paging

NameDescription
enablePaging(): voidTurns on paging.
disablePaging(): voidTurns off paging.
nextPage(): voidMoves to the next page.
prevPage(): voidMoves to the previous page.
changePageSize(pageSize: number): voidChanges page size.
setPagingConfig(config: PagingConfig): voidSets config for paging.

Visual

NameDescription
setTheme(theme: string | GuiTheme): voidSets theme.
setVerticalGrid(enabled: boolean): voidSets vertical grid.
setHorizontalGrid(enabled: boolean): voidSets horizontal grid.
setRowColoring(rowColoring: string | GuiRowColoring): voidSets row coloring.

Virtual scroll

NameDescription
enableVirtualScroll(): voidEnables virtual scroll.
disableVirtualScroll(): voidDisables virtual scroll.

Summaries

NameDescription
enableSummaries(): voidEnables summaries.
disableSummaries(): voidDisables summaries.

Sorting

NameDescription
setSortConfig(config: SortingConfig): voidSets configuration for sorting.

Related articles: