fix: row selection with incorrect values
This commit is contained in:
@@ -71,7 +71,7 @@ export const Computer = React.memo(() => {
|
||||
|
||||
//When values change, update selection
|
||||
useEffect(() => {
|
||||
const searchSelection = async () => {
|
||||
const searchSelection = async (values: Array<Record<string, unknown>>) => {
|
||||
const page_data = getState('_page_data');
|
||||
const pageSize = getState('pageSize');
|
||||
const keyField = getState('keyField') ?? 'id';
|
||||
@@ -85,6 +85,9 @@ export const Computer = React.memo(() => {
|
||||
? values?.[vi]
|
||||
: undefined
|
||||
);
|
||||
if (!key) {
|
||||
continue;
|
||||
}
|
||||
for (const p in page_data) {
|
||||
for (const r in page_data[p]) {
|
||||
const idx = Number(p) * pageSize + Number(r);
|
||||
@@ -115,7 +118,7 @@ export const Computer = React.memo(() => {
|
||||
};
|
||||
|
||||
if (values) {
|
||||
searchSelection().then((rowIndexes) => {
|
||||
searchSelection(values).then((rowIndexes) => {
|
||||
let rows = CompactSelection.empty();
|
||||
rowIndexes.forEach((r) => {
|
||||
if (r !== undefined) {
|
||||
|
||||
@@ -336,7 +336,9 @@ const { Provider, useStore: useGridlerStore } = createSyncStore<GridlerStoreStat
|
||||
},
|
||||
getRowIndexByKey: async (key: number | string) => {
|
||||
const state = get();
|
||||
|
||||
if (key === undefined || key === null) {
|
||||
return undefined;
|
||||
}
|
||||
let rowIndex = -1;
|
||||
if (state.ready) {
|
||||
const page_data = state._page_data;
|
||||
|
||||
Reference in New Issue
Block a user