MCPcopy
hub / github.com/ag-grid/ag-grid / createGrid

Function createGrid

community-modules/core/src/grid.ts:132–167  ·  view source on GitHub ↗
(
    eGridDiv: HTMLElement,
    gridOptions: GridOptions<TData>,
    params?: Params
)

Source from the content-addressed store, hash-verified

130 * @returns api to be used to interact with the grid.
131 */
132export function createGrid<TData>(
133 eGridDiv: HTMLElement,
134 gridOptions: GridOptions<TData>,
135 params?: Params
136): GridApi<TData> {
137 if (!gridOptions) {
138 _errorOnce('No gridOptions provided to createGrid');
139 return {} as GridApi;
140 }
141 const api = new GridCoreCreator().create(
142 eGridDiv,
143 gridOptions,
144 (context) => {
145 const gridComp = new GridComp(eGridDiv);
146 context.createBean(gridComp);
147 },
148 undefined,
149 params
150 );
151
152 // @deprecated v31 api no longer mutated onto the provided gridOptions
153 // Instead we place a getter that will log an error when accessed and direct users to the docs
154 // Only apply for direct usages of createGrid, not for frameworks
155 if (!Object.isFrozen(gridOptions) && !(params as GridParams)?.frameworkOverrides) {
156 const apiUrl = 'https://ag-grid.com/javascript-data-grid/grid-interface/#grid-api';
157 Object.defineProperty(gridOptions, 'api', {
158 get: () => {
159 _errorOnce(`gridOptions.api is no longer supported. See ${apiUrl}.`);
160 return undefined;
161 },
162 configurable: true,
163 });
164 }
165
166 return api;
167}
168/**
169 * @deprecated v31 use createGrid() instead
170 */

Callers 15

columnApi.test.tsFile · 0.90
ngAfterViewInitMethod · 0.90
mountedFunction · 0.90
initFunction · 0.90
initFunction · 0.90
initFunction · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90

Calls 3

_errorOnceFunction · 0.90
createMethod · 0.80
createBeanMethod · 0.80

Tested by 9

createMyGridFunction · 0.72
createMyGridFunction · 0.72
createMyGridFunction · 0.72
createMyGridFunction · 0.72
createMyGridFunction · 0.72
createMyGridFunction · 0.72
createMyGridFunction · 0.72
createMyGridFunction · 0.72
createMyGridFunction · 0.72