docs(changeset): Updated selected cols bug
This commit is contained in:
@@ -67,6 +67,7 @@ export const Computer = React.memo(() => {
|
||||
}
|
||||
);
|
||||
|
||||
//When values change, update selection
|
||||
useEffect(() => {
|
||||
const searchSelection = async () => {
|
||||
const page_data = getState('_page_data');
|
||||
@@ -128,40 +129,12 @@ export const Computer = React.memo(() => {
|
||||
}
|
||||
}, [values]);
|
||||
|
||||
//Fire onChange when selection changes
|
||||
useEffect(() => {
|
||||
const onChange = getState('onChange');
|
||||
if (onChange && typeof onChange === 'function') {
|
||||
const page_data = getState('_page_data');
|
||||
const pageSize = getState('pageSize');
|
||||
|
||||
const buffers = [];
|
||||
if (_gridSelectionRows) {
|
||||
for (const range of _gridSelectionRows) {
|
||||
let buffer = undefined;
|
||||
|
||||
for (const p in page_data) {
|
||||
for (const r in page_data[p]) {
|
||||
const idx = Number(p) * pageSize + Number(r);
|
||||
if (isNaN(idx)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Number(page_data[p][r]?._rownumber) === range + 1) {
|
||||
buffer = page_data[p][r];
|
||||
//console.log('Found row', range, idx, page_data[p][r]?._rownumber);
|
||||
break;
|
||||
} else if (idx === range + 1) {
|
||||
buffer = page_data[p][r];
|
||||
//console.log('Found row 2', range, idx, page_data[p][r]?._rownumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buffer !== undefined) {
|
||||
buffers.push(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
const getGridSelectedRows = getState('getGridSelectedRows');
|
||||
const buffers = getGridSelectedRows();
|
||||
|
||||
const _values = getState('values');
|
||||
|
||||
@@ -278,6 +251,7 @@ export const Computer = React.memo(() => {
|
||||
});
|
||||
}, [colOrder]);
|
||||
|
||||
//Initial Load
|
||||
useEffect(() => {
|
||||
if (!_glideref) {
|
||||
return;
|
||||
@@ -291,11 +265,12 @@ export const Computer = React.memo(() => {
|
||||
});
|
||||
}, [ready, loadPage]);
|
||||
|
||||
//Logic to select first row on mount
|
||||
useEffect(() => {
|
||||
const _events = getState('_events');
|
||||
const loadPage = () => {
|
||||
const selectFirstRowOnMount = getState('selectFirstRowOnMount');
|
||||
if (selectFirstRowOnMount) {
|
||||
if (ready && selectFirstRowOnMount) {
|
||||
const scrollToRowKey = getState('scrollToRowKey');
|
||||
if (scrollToRowKey && scrollToRowKey >= 0) {
|
||||
return;
|
||||
@@ -328,28 +303,28 @@ export const Computer = React.memo(() => {
|
||||
return () => {
|
||||
_events?.removeEventListener('loadPage', loadPage);
|
||||
};
|
||||
}, []);
|
||||
}, [ready]);
|
||||
|
||||
/// logic to apply the selected row.
|
||||
useEffect(() => {
|
||||
const ready = getState('ready');
|
||||
const ref = getState('_glideref');
|
||||
const getRowIndexByKey = getState('getRowIndexByKey');
|
||||
// useEffect(() => {
|
||||
// const ready = getState('ready');
|
||||
// const ref = getState('_glideref');
|
||||
// const getRowIndexByKey = getState('getRowIndexByKey');
|
||||
|
||||
if (scrollToRowKey && ref && ready) {
|
||||
getRowIndexByKey?.(scrollToRowKey).then((r) => {
|
||||
if (r !== undefined) {
|
||||
//console.log('Scrolling to selected row:', scrollToRowKey, r);
|
||||
ref.scrollTo(0, r);
|
||||
getState('_events').dispatchEvent(
|
||||
new CustomEvent('scrollToRowKeyFound', {
|
||||
detail: { rowNumber: r, scrollToRowKey: scrollToRowKey },
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [scrollToRowKey]);
|
||||
// if (scrollToRowKey && ref && ready) {
|
||||
// getRowIndexByKey?.(scrollToRowKey).then((r) => {
|
||||
// if (r !== undefined) {
|
||||
// //console.log('Scrolling to selected row:', scrollToRowKey, r);
|
||||
// ref.scrollTo(0, r);
|
||||
// getState('_events').dispatchEvent(
|
||||
// new CustomEvent('scrollToRowKeyFound', {
|
||||
// detail: { rowNumber: r, scrollToRowKey: scrollToRowKey },
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }, [scrollToRowKey]);
|
||||
|
||||
useEffect(() => {
|
||||
const ready = getState('ready');
|
||||
|
||||
Reference in New Issue
Block a user