buggy load() in unitview


I experience the following bug:
When I add events wia load(xmlfile) it always assigns the events to the leftmost unit, if (and only if) I am currently in unit_view.


// create new section
// load all events assigned to this section from database

Situation: I have one section (and appropriate events loaded)

  1. When I am in week_view (or day, month…) and I load another section everything is fine. When i switch to unit_view, it’s still fine.
  2. Instead, when i am in unit_view and add the second section from there all events show in the first column unit. When I switch to week view it is still wrongly assigned
  3. Instead, when I am in timeline_view and add the second section from there I get an error “this.order is null or not an object” in dhtmlxscheduler_timeline.js at position 5016
    I guess these two errors are related.

My (temporary) solution:

// create new section
// save current view mode
var currview = scheduler._mode;
// switch to week view
scheduler.setCurrentView(scheduler._date, 'week');  
// load all events assigned to this section from database
scheduler.load('load_events.asp?sec_ids='+sec_id+'&taskids=&'+Math.random(), function() {
  // switch back to former view mode
  scheduler.setCurrentView(scheduler._date, currview);  

This is a serious error in our environment, hope it is fixed soon, but you usually are rather fast. :slight_smile:


Assuming that you are using scheduler 2.3
Try to replace

// create new section sections.push({'key':sec_id,'label':sec_name}); // save current view mode var currview = scheduler._mode; // switch to week view scheduler.setCurrentView(scheduler._date, 'week');


// create new section sections.push({'key':sec_id,'label':sec_name}); // force update of collections and views scheduler.callEvent("onOptionsLoad",[]);

This is not working. Same problem as before.



Try changing your dhtmlxscheduler_units.js file with the one in the attach.
Also check sample how you can dynamically change sections. It works without events reloading but events from the removed sections won’t be displayed only in the Units view itself.



html, body{ margin:0px; padding:0px; height:100%; overflow:hidden; }

Best regards,
dhtmlxscheduler_units.zip (10.1 KB)

Thank you for your reply.

ad 1)
Sadly the new dhtmlxscheduler_units.js (and property.js???) has no effect in this matter

ad 2)
This is basically what i do now, but I do not have all the events loaded when scheduler is initalized but load some into scheduler when I add a new section.
So the events loaded in scheduler should match the corresponding ressources.
When i remove some ressource I also want to remove the corresponding events (but without using the deleteEvent() function, as deleting an event in our application really means “remove the association to that section” in database).
But this second issue is not a big deal, the occasional reload when sections are removed is OK.

The first problem however is more serious.
I guess it might be connected to the dynamic szenario. But adding sections and events in “normal” calendar view works fine…

Please also note the 3rd case in my original post (error in timeline view), as I think this might by connected…



Please check another sample, I am loading different events each time and they are displayed correctly, no errors are occurring.
Note the order: remove all events, change sections, onOptionsLoad, load events (and setCurrentView in the callback).


html, body{ margin:0px; padding:0px; height:100%; overflow:hidden; }
[/code] Best regards, Ilya

Thank you for that example.
The example works, but my real case still doesn’t. :frowning:
I found something new regarding this problem:
Only the events for the day I currently display (in unit view (and probably timeline)) are assigned wrongly. Other days are ok:
1: Load a section (a)
2: switch to unit view
3: load another section (b) (and its events)
-> (b)'s events are assigned to (a)
4: go back one day
-> (b)'s events are correctly assigned
5: one day forward again (same day as originally)
-> (b)'s events are still wrongly assigned to (a)

So it seems some event is fired on the current view only?

Not sure if this gives any clues.
There may be some quirk in my code but I can’t find the problem.
If the above is not hint enough, I will open a ticket with members support and upload the whole sourcefile, maybe you find something I overlooked.

Hello, Gerrit.

Try replacing your dhtmlxscheduler_units.js file with the attached one.

If it doesn’t help then please attach your source file here or in the support system. This could give us additional information.

Best regards,
dhtmlxscheduler_units_updated.ZIP (7 KB)

Still no success.
I will write a support request (name is “Kai Soelter”).

Another thing, probably related:
Please confirm the following problem:
If in unit view and scheduler.load() reads events with section_id===0 it assigns these events to the first section (leftmost column) even if the sections id is different from 0


scheduler.createUnitsView({ name:"unit", property:"section_id", list: sections, skip_incorrect: true });
Try adding skip_incorrect part to the settings object. Should work with the updated dhtmlxscheduler_units.js which I attached earlier. This option should remove events with the sections which are not present on the current units view (and will do nothing in other views).

With this option enabled I tried to reproduce this situation but it worked correctly.

Best regards,

The skip_incorrect: true parameter solves the matter!
It doesn’t live up to its name though, as it doesn’t seem to skip anything, but places the events as intended.
The problem with the error message in timeline view still exists.
Maybe there, too, the magical “skip_incorrect: true” could be added? :wink:

There are some historical reasons why by default events which doesn’t have a valid section are assigned to the first one. So that’s why this option skips rendering of ‘incorrect’ events even if they are loaded.

As for

As a temporary (or maybe not so temporary) solution you can try to modify timeline source files according to the instructions in the Adjust timeline view on the fly topic.
Are events from missing sections still displayed?

Best regards,

I am still not sure I understand.

The events do have valid section_id parameter.
When I use
skip_incorrect: true
They are all assigned correctly.
When I disable that option they are all assigned to the leftmost section (when using load() while in unit view).
Neither way anything is skipped, as in “not displayed at all”…

So it works for me now, but I am a littly nervous that this is more a coincidence than a fix cause your explanation seems to expect another behaviour…

Let’s say that we have an Unit view this only one section - ‘Section A’ which has key ‘section_id’ = 1. Now if we load following events into the scheduler:

scheduler.parse([ { start_date: "2009-06-30 09:00", end_date: "2009-06-30 12:00", text:"Task A-12458", section_id:1}, { start_date: "2009-06-30 12:00", end_date: "2009-06-30 20:00", text:"Task B-48865", section_id:2}, { start_date: "2009-06-30 08:00", end_date: "2009-06-30 12:00", text:"Task C-32421", section_id:3}, { start_date: "2009-06-30 12:00", end_date: "2009-06-30 18:00", text:"Task D-12458", section_id:4} ],"json");
Then all of them will be rendered and displayed. As you can see 3 of them has section_id which is not present in the current Units view and there were some reasons to ‘fix’ them and assign to the existing section – section_id = 1. So they all would appear there with their section_id property changed.

Now with the ‘skip_incorrect’ option = true such events will be discarded for units view (so only “Task A-12458” will be displayed). Their section_id should not be changed, they are simply skipped and not rendered. But all of them will be displayed in other views, e.g. ‘month’.

Best regards,

Well in my application it is like this:

  1. I add an section
  2. I switch to unit view
  3. programatically add another section and then load events assigned to this section, two columns now
    4a) Without “skip_incorrect: true” all events for section b are assigned to sectioan a
  • This is correct behaviour if the events section_id is invalid (as you described), BUT
    4b) With “skip_incorrect: true” enabled all the events are correctly assigned to section b
  • Expected behaviour (as of your explanation) would be that no events are displayed as there is obviously something wrong with them (see 4) )
    But Actually nothing is skipped at all, all events are assigned correctly.

So, I am confused (still happy, but confused happy :wink:


Got it, now I can explain this behavior.
scheduler.load by itself calls setCurrentView and only after it calls your callback function where you update units view.

So at the moment of this refresh there is no addition section and without skip_incorrect option loaded events are ‘fixed’. Only after that has occurred we add another section and refresh view. But at this point events are already has incorrect section_id and this is why they are rendered in the first column.
In case of ‘skip_incorrect=true’ during the first refresh (where we don’t have new section yet) they are simply skipped and during the second refresh (where we already have our new section) rendered in the new section correctly.

Best regards,

I see.
So it shouldn’t harm, leaving the skip_incorrect: true activated.

Thank you for the clarification!