Skip to content

Fix implementation on editing.changes accumulating #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 23.1.3+
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ASP.NET Core/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
<script>
function validateVisibleRows() {
const grid = $("#gridContainer").dxDataGrid("instance");
const currentChanges = grid.option("editing.changes");
const currentChanges = grid.option('editing.changes').filter(c => {
return Object.keys(c.data).length > 0;
});
const fakeChanges = grid.getVisibleRows().map(function (row) {
return { type: "update", key: row.data.ID, data: {} };
});
Expand Down
5 changes: 4 additions & 1 deletion Angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@

validateVisibleRows(): void {
const dataGridInstance = this?.dataGrid?.instance;
const currentChanges = (dataGridInstance?.option('editing.changes') as DxDataGridTypes.DataChange[]).filter((c) => {

Check failure on line 30 in Angular/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Angular

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return Object.keys(c.data).length > 0;
});
const fakeChanges = dataGridInstance
? dataGridInstance.getVisibleRows().map((row: DxDataGridTypes.Row): DxDataGridTypes.DataChange => ({ type: 'update', key: row.key, data: {} }))
: [];
this.changes = [...this.changes, ...fakeChanges];
this.changes = [...currentChanges, ...fakeChanges];
this.checked = true;
}

Expand Down
5 changes: 4 additions & 1 deletion React/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

const validateVisibleRows = React.useCallback(() => {
let dataGrid = grid?.current?.instance;
const currentChanges = (dataGrid?.option('editing.changes') as DataGridTypes.DataChange[]).filter((c) => {

Check failure on line 20 in React/src/App.tsx

View workflow job for this annotation

GitHub Actions / React

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return Object.keys(c.data).length > 0;
});
const fakeChanges = dataGrid
? dataGrid.getVisibleRows().map((row: DataGridTypes.Row): DataGridTypes.DataChange => ({ type: 'update', key: row.key, data: {} }))
: [];
// alternatively, you can use the DataGrid|option method to set a new changes array
setChanges([...changes, ...fakeChanges]);
setChanges([...currentChanges, ...fakeChanges]);
setClicked(true);
}, [changes]);

Expand Down
5 changes: 4 additions & 1 deletion Vue/src/components/HomeContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const dataGridRef = ref<DxDataGrid>();

const validateVisibleRows = () => {
const dataGridInstance = dataGridRef.value?.instance! as dxDataGrid;
const currentChanges = (dataGridInstance?.option('editing.changes') as DxDataGridTypes.DataChange[]).filter((c) => {
return Object.keys(c.data).length > 0;
});
const fakeChanges = dataGridInstance
? dataGridInstance
.getVisibleRows()
Expand All @@ -76,7 +79,7 @@ const validateVisibleRows = () => {
data: {}
}))
: [];
changes.value = [...changes.value, ...fakeChanges];
changes.value = [...currentChanges, ...fakeChanges];
clicked.value = true;
};

Expand Down
4 changes: 3 additions & 1 deletion jQuery/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@

function validateVisibleRows() {
const grid = $('#gridContainer').dxDataGrid('instance');
const currentChanges = grid.option('editing.changes');
const currentChanges = grid.option('editing.changes').filter(c => {

Check failure on line 46 in jQuery/src/index.js

View workflow job for this annotation

GitHub Actions / jQuery

Expected parentheses around arrow function argument

Check failure on line 46 in jQuery/src/index.js

View workflow job for this annotation

GitHub Actions / jQuery

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return Object.keys(c.data).length > 0;
});
const fakeChanges = grid.getVisibleRows().map((row) => ({ type: 'update', key: row.key, data: {} }));

grid.option('editing.changes', [...currentChanges, ...fakeChanges]);
Expand Down
Loading