Our state of the art Gantt chart


Post by Jerther »

Hello!

Here are the steps to replicate:

  • Load the Aggregation column demo
  • put the gantt instance in window:
    gantt = window.gantt = new Gantt({
  • Resize some columns in the left grid and move the splitter
  • In the console, get a serialized state of that grid:
    var x = JSON.stringify(gantt.subGrids.locked.grid.getState())
  • Now resize some columns and move the splitter again
  • In the console, restore the grid state:
    gantt.subGrids.locked.grid.applyState(JSON.parse(x))
  • This works fine. Now apply an insignificant change in the code panel to have the Gantt reloaded
  • Try to apply the state to the grid again:
    gantt.subGrids.locked.grid.applyState(JSON.parse(x))

Result:

  • Only the splitter is restored, all the columns remain as they are

Expected result:

  • All the columns widths are restored as well as the splitter position.

Now maybe I'm doing this wrong. I'm trying to save the currently shown columns and their widths, etc. I've also tried with gantt.subGrids.normal.grid.getState() and gantt.getState() with the corresponding applyState() but the results are a bit confusing, I mean not what I would expect. Like, applyState() on the locked grid also restores the timeAxis position? :?


Post by mats »

Looks like a bug yes, we'll investigate: https://github.com/bryntum/support/issues/1000


Post by Jerther »

I noticed some settings from the timeAxis are present in gantt.subGrids.locked.grid.getState(), so they were later restored. We found that useful so I ended up using Gantt.getState() and Gantt.applyState() instead and that works fine overall.

Later we may want not to save the timeaxis dates though. I think I would just delete those informations from the state object before saving it so they aren't there when applying the state back. Would that be fine?


Post by mats »

Yes should be (though haven't tested it yet)


Post Reply