Update sigpro-ui.js
This commit is contained in:
@@ -621,7 +621,7 @@ export const Modal = (props, children) => {
|
|||||||
|
|
||||||
/** GRID */
|
/** GRID */
|
||||||
export const Grid = (props) => {
|
export const Grid = (props) => {
|
||||||
const { data, options, class: className } = props;
|
const { data, options, api, on, class: className } = props;
|
||||||
let gridApi = null;
|
let gridApi = null;
|
||||||
|
|
||||||
return $html("div", {
|
return $html("div", {
|
||||||
@@ -631,10 +631,32 @@ export const Grid = (props) => {
|
|||||||
const { createGrid } = await import("./grid/grid.js");
|
const { createGrid } = await import("./grid/grid.js");
|
||||||
|
|
||||||
const initialData = typeof data === "function" ? data() : data;
|
const initialData = typeof data === "function" ? data() : data;
|
||||||
|
const initialOptions = typeof options === "function" ? options() : options;
|
||||||
|
|
||||||
const gridOptions = {
|
const gridOptions = {
|
||||||
...(typeof options === "function" ? options() : options),
|
...initialOptions,
|
||||||
theme: getTheme(isDark()),
|
theme: getTheme(isDark()),
|
||||||
rowData: initialData || [],
|
rowData: initialData || [],
|
||||||
|
onGridReady: (params) => {
|
||||||
|
gridApi = params.api;
|
||||||
|
if (api) api.current = gridApi;
|
||||||
|
if (on?.onGridReady) on.onGridReady(params);
|
||||||
|
},
|
||||||
|
onFilterChanged: (e) => on?.onFilterChanged?.(e),
|
||||||
|
onModelUpdated: (e) => on?.onModelUpdated?.(e),
|
||||||
|
onGridSizeChanged: (e) => on?.onGridSizeChanged?.(e),
|
||||||
|
onFirstDataRendered: (e) => on?.onFirstDataRendered?.(e),
|
||||||
|
onRowValueChanged: (e) => on?.onRowValueChanged?.(e),
|
||||||
|
onSelectionChanged: (e) => on?.onSelectionChanged?.(e),
|
||||||
|
onCellClicked: (e) => on?.onCellClicked?.(e),
|
||||||
|
onCellDoubleClicked: (e) => on?.onCellDoubleClicked?.(e),
|
||||||
|
onCellValueChanged: (e) => on?.onCellValueChanged?.(e),
|
||||||
|
onRowClicked: (e) => on?.onRowClicked?.(e),
|
||||||
|
onSortChanged: (e) => on?.onSortChanged?.(e),
|
||||||
|
onContextMenu: (e) => on?.onContextMenu?.(e),
|
||||||
|
onColumnResized: (e) => on?.onColumnResized?.(e),
|
||||||
|
onColumnMoved: (e) => on?.onColumnMoved?.(e),
|
||||||
|
onRowDataUpdated: (e) => on?.onRowDataUpdated?.(e)
|
||||||
};
|
};
|
||||||
|
|
||||||
gridApi = createGrid(container, gridOptions);
|
gridApi = createGrid(container, gridOptions);
|
||||||
@@ -656,6 +678,7 @@ export const Grid = (props) => {
|
|||||||
container._cleanups.add(() => {
|
container._cleanups.add(() => {
|
||||||
if (gridApi) {
|
if (gridApi) {
|
||||||
gridApi.destroy();
|
gridApi.destroy();
|
||||||
|
if (api) api.current = null;
|
||||||
gridApi = null;
|
gridApi = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user