Skip to content

Commit

Permalink
Merge pull request #515 from revolist/514-row-size-is-not-getting-upd…
Browse files Browse the repository at this point in the history
…ated-if-no-custom-sizes-provided

#514 - fixed row size init
  • Loading branch information
revolist authored Aug 1, 2024
2 parents ea4e321 + cdaf2df commit f803736
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/components/revoGrid/revo-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
VNode,
Host,
} from '@stencil/core';
import each from 'lodash/each';

import ColumnDataProvider, {
ColumnCollection,
Expand Down Expand Up @@ -1005,7 +1004,7 @@ export class RevoGridComponent {
@Watch('rowSize') rowSizeChanged(s: number) {
// clear existing data
this.dimensionProvider.setSettings({ originItemSize: s }, 'rgRow');
this.rowDefChanged(this.rowDefinitions, this.rowDefinitions);
this.rowDefChanged(this.rowDefinitions, this.rowDefinitions, 'rowSize', true);
}

@Watch('theme') themeChanged(
Expand Down Expand Up @@ -1106,6 +1105,8 @@ export class RevoGridComponent {
@Watch('rowDefinitions') rowDefChanged(
after: RowDefinition[],
before?: RowDefinition[],
_watchName?: string,
forceUpdate = true,
) {
const {
detail: { vals: newVal, oldVals: oldVal },
Expand All @@ -1119,19 +1120,26 @@ export class RevoGridComponent {
if (oldVal) {
const remove = rowDefinitionRemoveByType(oldVal);
// clear all old data and drop sizes
each(remove, (_, t: DimensionRows) => {
this.dimensionProvider.clearSize(
t,
this.dataProvider.stores[t].store.get('source').length,
);
});
for (const t in remove) {
if (remove.hasOwnProperty(t)) {
const type = t as DimensionRows;
const store = this.dataProvider.stores[type];
const sourceLength = store.store.get('source').length;
this.dimensionProvider.clearSize(type, sourceLength);
}
}
}
if (!newVal.length) {
return;
if (forceUpdate) {
this.dimensionProvider.setCustomSizes('rgRow', {});
} else {
return;
}
}
each(newRows, (r, k: DimensionRows) =>
this.dimensionProvider.setCustomSizes(k, r.sizes || {}),
);
Object.entries(newRows).forEach(([k, r]) => {
const type = k as DimensionRows;
this.dimensionProvider.setCustomSizes(type, r.sizes || {});
});
}

@Watch('trimmedRows') trimmedRowsChanged(
Expand Down

0 comments on commit f803736

Please sign in to comment.