Giter Site home page Giter Site logo

Comments (6)

ahwgs avatar ahwgs commented on May 10, 2024 2

Please use v0.3.0 version. This issue has been fixed
@synapse @psybor

from react-gantt.

psybor avatar psybor commented on May 10, 2024 1

Please provide the minimum recurrence demo

It's simple, just as @synapse said, I store data in the AppComponent. When onUpdate, I setData.
Then, every change triggers a whole update.

import dayjs from 'dayjs'
import RcGantt from 'rc-gantt'
import React, { useState } from 'react'

interface Data {
  name: string
  startDate: string
  endDate: string
  id: number
}

const _data = Array.from({ length: 100 })
  .fill({
    name: '一个名称一个名称一个名称一个名称',
    startDate: dayjs().format('YYYY-MM-DD'),
    endDate: dayjs().add(1, 'week').format('YYYY-MM-DD'),
  })
  .map((d: any, idx) => ({
    ...d,
    id: idx,
  })) as Data[]

const App = () => {
  const [data, setData] = useState(_data)
  return (
    <div style={{ width: '100%', height: 500 }}>
      <RcGantt<Data>
        lang='zh-CN'
        data={data}
        columns={[
          {
            name: 'name',
            label: '名称',
            width: 100,
          },
        ]}
        onUpdate={async (row, startDate, endDate) => {
          console.log('update', row, startDate, endDate)
          setData(prev => {
            const newList = [...prev]
            const index = newList.findIndex(val => val.id === row.id)
            newList[index] = {
              ...row,
              startDate: dayjs(startDate).format('YYYY-MM-DD'),
              endDate: dayjs(endDate).format('YYYY-MM-DD'),
            }
            return newList
          })
          return true
        }}
      />
    </div>
  )
}

export default App

from react-gantt.

ahwgs avatar ahwgs commented on May 10, 2024

Can you provide a moving image demonstration?

from react-gantt.

synapse avatar synapse commented on May 10, 2024

Sure thing @ahwgs, here it is (also had to disable toggling the open/close of the sidebar since it would constantly close it).

gantt.mov

from react-gantt.

ahwgs avatar ahwgs commented on May 10, 2024

Please provide the minimum recurrence demo

from react-gantt.

synapse avatar synapse commented on May 10, 2024

@ahwgs It should be simple to replicate it yourself in your dev-env. All your example use a const array as the source of the data and non of the Gantt components update it. In my case the Gantt data is stored in the component's state and on onUpdate I'm just updating the correct gantt row.
Another way to do it would be just to trigger a component refresh onUpdate - should have that same effect

from react-gantt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.