Readonly section in timeline

Dear All,

I would like to ask if it is possible to make lightbox readonly for all events in the timeline view except for one section so that events in that section would remain editable? (existing events)

Also, is it possible to show lightbox only if the empty space in that section was double clicked and not to show for other sections? (adding new event)

Thank you in advance
Best regards

Hello,

  1. You can catch double click on event bar and switch form to readonly when it’s necessary

  2. It also can be done by catching the related events of the scheduler.
    You will need three of them -
    onDblClick - to switch readonly lightbox
    onBeforeDrag, onEmptyClick - to prevent resizing and adding new events on double click.
    The code might be following[code] var editableSection = 1;

     	//readonly form
     	scheduler.attachEvent("onDblClick", function(id){
     		if(id && scheduler.getEvent(id)){
     			var ev = scheduler.getEvent(id);
     			if(ev.section_id == editableSection){
     				scheduler.config.readonly_form = false;
     			}else{
     				scheduler.config.readonly_form = true;
     			}
     		}
     		return true;
     	});
    
     	//resize and create by dragging area
     	scheduler.attachEvent("onBeforeDrag", function (event_id, mode, e){
     		return (scheduler.getActionData(e).section == editableSection);
     	});
     	//double-click on empty space
     	scheduler.attachEvent("onEmptyClick", function (date, e){
     		var section = scheduler.getActionData(e).section;
     		if(section == editableSection){
     			scheduler.config.dblclick_create = true;
     		}else{
     			scheduler.config.dblclick_create = false;
     		}
     	});[/code]
    

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

Thanks for your reply Aliaksandr,
Your code works just fine in timeline view, however it also modifies the behaviour of day, week and month views. In these views I was unable to add new event.
Could you modify your code, so that it only works in timeline view, please?
Thank you

Hi,
try something like this:[code]function isTimelineView(){
//scheduler.matrix stores configurations of all timelines, added to the scheduler
//so, if current view is found in this container - then it’s timeline
return !!scheduler.matrix[scheduler.getState().mode];
}

var editableSection = 1;

//readonly form
scheduler.attachEvent(“onDblClick”, function(id){
if(!isTimelineView()) return true;

if(id && scheduler.getEvent(id)){
	var ev = scheduler.getEvent(id);
	if(ev.section_id == editableSection){
		scheduler.config.readonly_form = false;
	}else{
		scheduler.config.readonly_form = true;
	}
}
return true;

});

//resize and create by dragging area
scheduler.attachEvent(“onBeforeDrag”, function (event_id, mode, e){
if(!isTimelineView()) return true;

return (scheduler.getActionData(e).section == editableSection);

});
//double-click on empty space
scheduler.attachEvent(“onEmptyClick”, function (date, e){
if(!isTimelineView()) return true;

var section = scheduler.getActionData(e).section;
if(section == editableSection){
	scheduler.config.dblclick_create = true;
}else{
	scheduler.config.dblclick_create = false;
}

});[/code]