How to use deleteMarkedTimespan with id?

Hi,

How do I delete a marked timespan by specifying an id? The docs example literally shows you can just pass the id of a created timespan into the deleteMarkedTimespan method:

This, however, doesn’t seem to work for me. Here is the example: DHTMLX Snippet Tool
Click the “Remove Blocked” button - nothing happens despite the fact I am passing the id. If I don’t pass the id, it removes all the blocked successfully but I want to be able to remove particular timespans only.

Thanks.

You are returning only the first ID when several are created (please note: even when passing only 1 “configuration” object → several configs are created). What’s the reason behind this?
Are they linked in some object? In which? (but it doesn’t look so)

Then you try to look up the config of the timespan by the id but you find only the one which you returned, of course… while ignoring the rest which never get removed from the _marked_timespans array.

Possible solution:

  1. return an array from addMarkedTimespan
  2. use this array in deleteMarkedTimespan as param instead of “id” /and improve your if (typeof configuration != "object") check, of course, as it would be true for the array
  3. and then remove all the passed id configs from the _marked_timespans array

Hello @fxfn ,

It looks like an issue on our end, thank you for noticing it, and for suggestions.

I sent it to our dev team, and they will work on a fix, unfortunately, there is no ETA.

As a temporary workaround, you can delete timespans by config, which may look like follows:

var id1Config  = {
  days:  [1],   
  zones: "fullday", 
  css:   "gray_section" 
}
var id2Config  = {
  days:  [3,5],   
  zones: "fullday", 
  css:   "gray_section" 
}

var id1 = scheduler.addMarkedTimespan(id1Config);
var id2 = scheduler.addMarkedTimespan(id2Config);
scheduler.updateView();


function deleteByConfig(){
  scheduler.deleteMarkedTimespan(id2Config);  
  scheduler.updateView();  
}

Here is a demo:
http://snippet.dhtmlx.com/5/131d7d2b0

Kind regards,

Thanks for your reply, @Siarhei

I tested removing them like that but sadly I cannot use it because it removes the overlapping blocked timespan as well, see this: http://snippet.dhtmlx.com/5/fa38f0aae

I added an additional marked timespan (id3) for days 3 and 5. If you click the delete button it removes them, too. I do not want to remove those.