Skip to content
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

[#888] Grid Virtual scroll 관련 이슈 수정 #889

Merged
merged 2 commits into from
Sep 15, 2021
Merged
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
1 change: 1 addition & 0 deletions src/components/grid/Grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ export default {
stores,
sortInfo,
filterInfo,
elementInfo,
setSort,
setFilter,
updateVScroll,
Expand Down
69 changes: 36 additions & 33 deletions src/components/grid/uses.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCurrentInstance } from 'vue';
import { getCurrentInstance, nextTick } from 'vue';
import { isEqual, uniqBy } from 'lodash-es';
import { numberWithComma } from '@/common/utils';

Expand Down Expand Up @@ -114,7 +114,7 @@ export const scrollEvent = (params) => {
const isHorizontal = !(scrollLeft === lastLeft);
const isVertical = !(scrollTop === lastTop);

if (isVertical) {
if (isVertical && bodyEl.clientHeight) {
updateVScroll();
}

Expand Down Expand Up @@ -236,7 +236,9 @@ export const resizeEvent = (params) => {
}

calculatedColumn();
updateVScroll();
if (elementInfo.body?.clientHeight) {
updateVScroll();
}
};
/**
* column resize 이벤트를 처리한다.
Expand Down Expand Up @@ -762,6 +764,7 @@ export const storeEvent = (params) => {
stores,
sortInfo,
filterInfo,
elementInfo,
setSort,
setFilter,
updateVScroll,
Expand All @@ -773,44 +776,44 @@ export const storeEvent = (params) => {
* @param {boolean} makeIndex - 인덱스 생성 유무
*/
const setStore = (value, makeIndex = true) => {
const store = [];
let checked;
let selected = false;
nextTick(() => {
const store = [];
let checked;
let selected = false;
if (makeIndex) {
let hasUnChecked = false;

for (let ix = 0; ix < value.length; ix++) {
checked = props.checked.includes(value[ix]);
if (!checked) {
hasUnChecked = true;
}

if (makeIndex) {
let hasUnChecked = false;
if (!selected && isEqual(selectInfo.selectedRow, value[ix])) {
selectInfo.selectedRow = value[ix];
selected = true;
}

for (let ix = 0; ix < value.length; ix++) {
checked = props.checked.includes(value[ix]);
if (!checked) {
hasUnChecked = true;
store.push([ix, checked, value[ix]]);
}

if (!selected && isEqual(selectInfo.selectedRow, value[ix])) {
selectInfo.selectedRow = value[ix];
selected = true;
if (!selected) {
selectInfo.selectedRow = [];
}

store.push([ix, checked, value[ix]]);
checkInfo.isHeaderChecked = value.length > 0 ? !hasUnChecked : false;
stores.originStore = store;
}

if (!selected) {
selectInfo.selectedRow = [];
if (filterInfo.isFiltering) {
setFilter();
}

checkInfo.isHeaderChecked = value.length > 0 ? !hasUnChecked : false;
stores.originStore = store;
}

if (filterInfo.isFiltering) {
setFilter();
}

if (sortInfo.sortField) {
setSort();
}

updateVScroll();
if (sortInfo.sortField) {
setSort();
}
if (elementInfo.body?.clientHeight) {
updateVScroll();
}
});
};
/**
* 컴포넌트의 변경 데이터를 store에 업데이트한다.
Expand Down