Block from X date to the past

Hi,

I’ve a timeline where I’d like to block, for every different folder, all the days before an specific date.

For example:

(Folder1)
(Item1)
(Item2)
(Folder2)
(Item1)
(Item2)

The items from the folder 1 must have blocked all the days before 2014-11-01 and the items from the folder 2 must have blocked all the days before 2014-10-01.

I tried with an iterative call to this function:

[code]function bloqueja_passat(date, folderId) {
var t = data.split(/[- :]/);
var dateBlock = new Date(t[0], t[1]-1, t[2]);

    scheduler.addMarkedTimespan({
        start_date: new Date(1900,1,1),
        end_date: dateBlock,
        zones: "fullday",
        css: "bloquejat",
        type:  "dhx_time_block",
        sections: {
            timeline_week: folderId,
            timeline_day: folderId
        }
    });
}[/code]

But is veeeery slow!!

How can I do it?

:unamused:

The code was bad, I used it with indicating the itemId in the sections property, like that:

function bloqueja_passat(date, folderId) {
        var t = data.split(/[- :]/);
        var dateBlock = new Date(t[0], t[1]-1, t[2]);
       
        scheduler.addMarkedTimespan({
            start_date: new Date(1900,1,1),
            end_date: dateBlock,
            zones: "fullday",
            css: "bloquejat",
            type:  "dhx_time_block",
            sections: {
                timeline_week: itemId,
                timeline_day: itemrId
            }
        });
    }

In addition to the question about the slowness of this function, I’d like to ask if it is possible to block all the items inside a folder, indicating only the folder:

function bloqueja_passat(date, folderId) {
        var t = data.split(/[- :]/);
        var dateBlock = new Date(t[0], t[1]-1, t[2]);
       
        scheduler.addMarkedTimespan({
            start_date: new Date(1900,1,1),
            end_date: dateBlock,
            zones: "fullday",
            css: "bloquejat",
            type:  "dhx_time_block",
            sections: {
                timeline_week: folderId,
                timeline_day: folderId
            }
        });
    }

This code blocks only the folder, no its items.

Pushing it, trying to get some suggestion… :slight_smile:

Hi,
currently there are some known performance issues regarding a big marked timespans.
What can be done in order to block and highlight the past dates - is to dinamically add a marked timespan for the visible area.

check this sample
docs.dhtmlx.com/scheduler/snippet/6982771b

docs.dhtmlx.com/scheduler/api__s … event.html
docs.dhtmlx.com/scheduler/api__s … espan.html
docs.dhtmlx.com/scheduler/api__s … espan.html

Thx! It works!

I need it to work with different blocking dates for every section. Hope this can helps someone:

var blocks_id = [];
var blocks_to = [];
blocks_to[15] = new Date(2015, 2, 4);
blocks_to[16] = new Date(2015, 2, 5);
blocks_to[17] = new Date(2015, 2, 6);

scheduler.attachEvent("onBeforeViewChange", function(old_mode,old_date,mode,date){
	if(time_id.length > 0) {
		time_id.forEach(function(element) {
			scheduler.deleteMarkedTimespan(element);
		});
		time_id = [];
	}

	var view_from = scheduler.date[mode + "_start"](new Date(date));
	var view_to = scheduler.date.add(view_from, 1, mode);
	
	blocks_to.forEach(function(element, index) {
		id = scheduler.addMarkedTimespan({
			start_date: view_from,
			end_date: new Date(Math.min(+element, +view_to)),
			css: "bloquejat",
			type: "dhx_time_block",
			sections: {
				timeline_week: index,
				timeline_day: index
			}
		});
		time_id.push(id);
	});
});