Our pure JavaScript Scheduler component


Post by Dev@2609 »

hi team,

I am trying out the angular drag from grid example to auto reschedule the taskS on overlap but it does not work and tasks overlap.

This is the format of my json. Is anything incorrect in the dataset format?
 "events"     : {
        "rows" : [
            {
                "id"           : "1",
                "resourceId"   : 1,
                "name"         : "Manufacturing",
                "iconCls"      : "b-fa b-fa-diamond",
                "startDate"    : "2017-04-05",
                "endDate"      : "2017-04-05",
                "eventColor"  : "gray"
                  },
                 {   "id"           : "2",
                "resourceId"   : 1,
                "name"         : "Manufacturing2",
                "iconCls"      : "b-fa b-fa-diamond",
                "startDate"    : "2017-04-06",
                "endDate"      : "2017-04-06",
                "eventColor"  : "green"}
                ]
                }

Post by mats »

What are the steps to reproduce? Do you expect your initial data to be cleaned up? It doesn't work like that.

Post by Dev@2609 »

hi mats,
To reporoduce, just replace the data.json content in angular drag from grid example with the format mentioned above. If you want I can share the json file.
The auto reschedule logic works with the default data.json file provided in the example, but not with the json format I am using.

Post by mats »

You have not provided us any step by step.

Post by Dev@2609 »

Mats, I would need to send the data.json file which contains the events data I need to populate on UI. Shall I send seperately or DM to you?

Steps:
1. Replace the content the data.json file in angular drag from grid example with the file mentioned above
2. Change the start dates and end dates.

Run the solution, hit auto reschedule button, Drag an event and drop on another, It wont get shifted.

Post by mats »

It's because you have copy pasted code and hoped that it would work. Please review code before copying, it's explained in the code that it only modifies events *in the future*. Remove this check and it will work as you want:

TaskStore.js
// Split tasks into future and earlier tasks, ignoring tasks in the past
            eventRecord.resource.events.forEach(event => {
                // Don't modify events in the past
                if (event.endDate > Date.now() && event !== eventRecord) {
                    if (event.startDate >= eventRecord.startDate) {
                        futureEvents.push(event);
                    }
                    else {
                        earlierEvents.push(event);
                    }
                }
            });

Post by Dev@2609 »

Hi Mats,

Removing Date.now() fixed this. Thanks!!!

Post Reply