gantt icon indicating copy to clipboard operation
gantt copied to clipboard

[BUG] I create startDate and endDate in rowtable, but when i change data in table, data not update, therefor data in gantt is old data

Open dat16720 opened this issue 10 months ago • 4 comments

[BUG] I create startDate and endDate in rowtable, but when i change data in table, data not update, therefor data in gantt is old data

dat16720 avatar Apr 01 '24 03:04 dat16720

paste your minimum reproduction code

jeremyjone avatar Apr 01 '24 04:04 jeremyjone

	I change data in collumn and refetch data, but new data not update, so row in <template #default="{ row }"> is old data
		`<XGanttColumn prop="timeline" :merge="merge5" width="100">
			<template #title="data">
				<div>
					title timeline
				</div>
			</template>
			<template #default="{ row }">
				<div v-show="!row.phaseId">
					<!-- timeline={{ fromDate: detailProject?.fromDate, toDate: detailProject?.toDate }} -->
					<FieldRangeDate
						:placeholder="['DD/MM/YYYY', 'DD/MM/YYYY']"
						:value="{ fromDate: row?.startDate, toDate: handleEndDate(row?.endDateAdd) }"
						:onSubmit="(value) => handleUpdateFieldValue(row._id, 'timeline', value)"
					/>
				</div>
			</template>
		</XGanttColumn>`

dat16720 avatar Apr 01 '24 05:04 dat16720

	I change data in collumn and refetch data, but new data not update, so row in <template #default="{ row }"> is old data
		`<XGanttColumn prop="timeline" :merge="merge5" width="100">
			<template #title="data">
				<div>
					title timeline
				</div>
			</template>
			<template #default="{ row }">
				<div v-show="!row.phaseId">
					<!-- timeline={{ fromDate: detailProject?.fromDate, toDate: detailProject?.toDate }} -->
					<FieldRangeDate
						:placeholder="['DD/MM/YYYY', 'DD/MM/YYYY']"
						:value="{ fromDate: row?.startDate, toDate: handleEndDate(row?.endDateAdd) }"
						:onSubmit="(value) => handleUpdateFieldValue(row._id, 'timeline', value)"
					/>
				</div>
			</template>
		</XGanttColumn>`

reload data

jeremyjone avatar Apr 01 '24 07:04 jeremyjone

yes reload data, but it not work. I realize this code in useInView, i think problem, but i don't know how to fix

watch( () => [top.value, bottom.value, store.$data.flatData], () => { for (let i = inView.length - 1; i >= 0; i--) { if ( inView[i].hide || inView[i].flatIndex <= top.value || inView[i].flatIndex >= bottom.value || store.$data.flatData[inView[i].flatIndex].id !== inView[i].id ) { inView.splice(i, 1); } } for (let i = top.value; i < bottom.value; i++) { if (!~inView.findIndex((v) => v.flatIndex === i)) { const oldIndex = inView.findIndex((v) => v.flatIndex === store.$data.flatData[i].flatIndex); if (~oldIndex) { inView.splice(oldIndex, 1, store.$data.flatData[i]); } else { inView.push(store.$data.flatData[i]); } } } }, );

 if i try this code, reRender all, The screen will flicker,
 `watch(
	() => [top.value, bottom.value, store.$data.flatData],
	() => {
		for (let i = inView.length - 1; i >= 0; i--) {
			if (
				inView[i].hide ||
				inView[i].flatIndex <= top.value ||
				inView[i].flatIndex >= bottom.value ||
				store.$data.flatData[inView[i].flatIndex].id !== inView[i].id
			) {
				inView.splice(i, 1);
			}
		}

		for (let i = top.value; i < bottom.value; i++) {
			const dataIndex = store.$data.flatData[i].flatIndex;
			const existingIndex = inView.findIndex((v) => v.flatIndex === dataIndex);
			if (existingIndex !== -1) {
				inView.splice(existingIndex, 1, store.$data.flatData[i]);
			} else {
				inView.push(store.$data.flatData[i]);
			}
		}
	},
);`	 

dat16720 avatar Apr 01 '24 07:04 dat16720

yes reload data, but it not work. I realize this code in useInView, i think problem, but i don't know how to fix

watch( () => [top.value, bottom.value, store.$data.flatData], () => { for (let i = inView.length - 1; i >= 0; i--) { if ( inView[i].hide || inView[i].flatIndex <= top.value || inView[i].flatIndex >= bottom.value || store.$data.flatData[inView[i].flatIndex].id !== inView[i].id ) { inView.splice(i, 1); } } for (let i = top.value; i < bottom.value; i++) { if (!~inView.findIndex((v) => v.flatIndex === i)) { const oldIndex = inView.findIndex((v) => v.flatIndex === store.$data.flatData[i].flatIndex); if (~oldIndex) { inView.splice(oldIndex, 1, store.$data.flatData[i]); } else { inView.push(store.$data.flatData[i]); } } } }, );

 if i try this code, reRender all, The screen will flicker,
 `watch(
	() => [top.value, bottom.value, store.$data.flatData],
	() => {
		for (let i = inView.length - 1; i >= 0; i--) {
			if (
				inView[i].hide ||
				inView[i].flatIndex <= top.value ||
				inView[i].flatIndex >= bottom.value ||
				store.$data.flatData[inView[i].flatIndex].id !== inView[i].id
			) {
				inView.splice(i, 1);
			}
		}

		for (let i = top.value; i < bottom.value; i++) {
			const dataIndex = store.$data.flatData[i].flatIndex;
			const existingIndex = inView.findIndex((v) => v.flatIndex === dataIndex);
			if (existingIndex !== -1) {
				inView.splice(existingIndex, 1, store.$data.flatData[i]);
			} else {
				inView.push(store.$data.flatData[i]);
			}
		}
	},
);`	 

This code no problem in my env and who uses it. If you have some minimum reproduction code, I can test it.

jeremyjone avatar Apr 15 '24 03:04 jeremyjone