clear comments
This commit is contained in:
@@ -22,7 +22,6 @@ export const Grid = (props, lang) => {
|
|||||||
const initialData = typeof data === "function" ? data() : data;
|
const initialData = typeof data === "function" ? data() : data;
|
||||||
const initialOptions = typeof options === "function" ? options() : options;
|
const initialOptions = typeof options === "function" ? options() : options;
|
||||||
|
|
||||||
// Eventos comunes de AG Grid
|
|
||||||
const commonEvents = [
|
const commonEvents = [
|
||||||
'onFilterChanged', 'onModelUpdated', 'onGridSizeChanged',
|
'onFilterChanged', 'onModelUpdated', 'onGridSizeChanged',
|
||||||
'onFirstDataRendered', 'onRowValueChanged', 'onSelectionChanged',
|
'onFirstDataRendered', 'onRowValueChanged', 'onSelectionChanged',
|
||||||
@@ -65,10 +64,10 @@ export const Grid = (props, lang) => {
|
|||||||
|
|
||||||
gridApi = createGrid(container, gridOptions);
|
gridApi = createGrid(container, gridOptions);
|
||||||
|
|
||||||
// Watch para cambios en los datos
|
const stopData = $watch([data], () => {
|
||||||
const stopData = $watch(() => {
|
if (!gridApi || gridApi.isDestroyed()) return;
|
||||||
const newData = typeof data === "function" ? data() : data;
|
const newData = typeof data === "function" ? data() : data;
|
||||||
if (gridApi && !gridApi.isDestroyed() && Array.isArray(newData)) {
|
if (Array.isArray(newData)) {
|
||||||
const currentData = gridApi.getGridOption("rowData");
|
const currentData = gridApi.getGridOption("rowData");
|
||||||
if (newData !== currentData) {
|
if (newData !== currentData) {
|
||||||
gridApi.setGridOption("rowData", newData);
|
gridApi.setGridOption("rowData", newData);
|
||||||
@@ -76,8 +75,7 @@ export const Grid = (props, lang) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Watch para cambios de tema
|
const stopTheme = $watch([isDark], () => {
|
||||||
const stopTheme = $watch(() => {
|
|
||||||
if (gridApi && !gridApi.isDestroyed()) {
|
if (gridApi && !gridApi.isDestroyed()) {
|
||||||
const dark = isDark();
|
const dark = isDark();
|
||||||
const newTheme = getTheme(dark);
|
const newTheme = getTheme(dark);
|
||||||
@@ -88,14 +86,12 @@ export const Grid = (props, lang) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ⚠️ IMPORTANTE: Solo actualizar opciones seguras
|
|
||||||
// No actualizar columnDefs, rowData, o theme dinámicamente
|
|
||||||
const safeOptions = ['pagination', 'paginationPageSize', 'suppressRowClickSelection',
|
const safeOptions = ['pagination', 'paginationPageSize', 'suppressRowClickSelection',
|
||||||
'rowSelection', 'enableCellTextSelection', 'ensureDomOrder',
|
'rowSelection', 'enableCellTextSelection', 'ensureDomOrder',
|
||||||
'stopEditingWhenCellsLoseFocus', 'enterMovesDown', 'enterMovesDownAfterEdit'];
|
'stopEditingWhenCellsLoseFocus', 'enterMovesDown', 'enterMovesDownAfterEdit'];
|
||||||
|
|
||||||
const stopOptions = $watch(() => {
|
const stopOptions = $watch([options], () => {
|
||||||
if (gridApi && !gridApi.isDestroyed() && options) {
|
if (!gridApi || gridApi.isDestroyed() || !options) return;
|
||||||
const newOptions = typeof options === "function" ? options() : options;
|
const newOptions = typeof options === "function" ? options() : options;
|
||||||
safeOptions.forEach(key => {
|
safeOptions.forEach(key => {
|
||||||
if (newOptions[key] !== undefined) {
|
if (newOptions[key] !== undefined) {
|
||||||
@@ -106,10 +102,8 @@ export const Grid = (props, lang) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Limpieza
|
|
||||||
container._cleanups.add(stopData);
|
container._cleanups.add(stopData);
|
||||||
container._cleanups.add(stopTheme);
|
container._cleanups.add(stopTheme);
|
||||||
container._cleanups.add(stopOptions);
|
container._cleanups.add(stopOptions);
|
||||||
|
|||||||
Reference in New Issue
Block a user