UNPKG

@adaptabletools/adaptable

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

33 lines (32 loc) 1.25 kB
import * as ModuleConstants from '../../Utilities/Constants/ModuleConstants'; import * as InternalRedux from '../../Redux/ActionsReducers/InternalRedux'; import { ApiBase } from './ApiBase'; import { DataSetInternalApi } from '../Internal/DataSetInternalApi'; export class DataSetApiImpl extends ApiBase { constructor(_adaptable) { super(_adaptable); this.internalApi = new DataSetInternalApi(_adaptable); } getDataSets() { return this.getDataSetOptions()?.dataSets ?? []; } getCurrentDataSet() { let currentDataSetName = this.getAdaptableState().Internal.CurrentDataSet; return this.getDataSetByName(currentDataSetName); } getDataSetByName(dataSetName) { return this.getDataSets().find((a) => a.name == dataSetName); } setDataSet(dataSetName) { const dataSet = this.getDataSetByName(dataSetName); if (this.checkItemExists(dataSet, dataSetName, 'Data Source')) { this.dispatchAction(InternalRedux.DataSetSelect(dataSet)); } } clearCurrentDataSet() { this.dispatchAction(InternalRedux.DataSetSelect(null)); } openDataSetSettingsPanel() { this.showModulePopup(ModuleConstants.DataSetModuleId); } }