Our blazing fast Grid component built with pure JavaScript


Post by udo »

hi,

I am using this example as a base to customize it towards what I need:

I would like copy(!) the tasks from that list on the right so when I drag them to the scheduler, they remain in the list and can be dragged and assigned multiple times.
note: now (in the example) when a task is dragged, it is removed from the list...

initially I thought this would be done through cloneTarget but it is not...

could you point me into the proper direction?

thanks, udo


Post by tasnim »

You just need to remove this line

(grid.store as Store).remove(task);

in the app.component.ts in the onDrop method and you'll be good to go.

What the onDrop method does is that it when you drop a task to a scheduler from a grid. it converts it to a native scheduler event and checks if it drops in a valid place or not then it removes the dropped item from the grid and add the item to the eventStore.

NOTE : If a task in the external grid has an id, then if you try to set it twice then you have to remove it or somehow do something otherwise it'll be a conflict

Good Luck :),
Tasnim


Post by udo »

thank you tasnim. removing the id does not let me assign it multiple times :| when I drag it another time, the initial one is moved to the new location...

there must be something else...


Post by tasnim »

You need to copy https://bryntum.com/docs/scheduler/api/Core/data/Model#function-copy the task

here is how you can achieve this:


// after task.setStartDate()
const copy = task.copy(targetEventRecord);
                
copy.assign(resource); schedule.eventStore.add(copy);

Good Luck :),
Tasnim


Post by udo »

thank you very much tasnim! works like a charm :)

for completeness, I changed the original example code

if (date) {
  // Remove from grid first so that the data change
  // below does not fire events into the grid.
  (grid.store as Store).remove(task);

  task.setStartDate(date, true);
  // task.startDate = date;
  task.resource = context.resource;
  scheduler.eventStore.add(task);
}

to

if (date) {
  task.setStartDate(date, true);
  const copy = task.copy(targetEventRecord);
  copy.assign(context.resource);
  scheduler.eventStore.add(copy);
}

Post Reply