Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Tys von Gaza on Dec 10, 2009 17:53
open dhtmlx forum
dhtmlxScheduler permissions on Unit view and classes on Agenda/Year view

So I've mostly got permissions working ok with all the calendar views. I switched my day view to use the Unit view. It works fine when I attach a function to onClick, onDblClick and onBeforeDrag to restrict an action. However if I drag an event that I do have permission to edit to a column in the Unit view which I don't have permission to, it moves (and updates) the event.

I tried hooking into the onBeforeDataSending event on the data processor which gets fired, but even when I return false it doesn't roll back the change and the event stays in the column it isn't allowed to be in.

Any advice to restrict the column an event can get dragged into?


The other two issues are minor. Is it possible to add a css class to the Agenda and Year Tooltip's for each calendar event like the Day/Week/Month view?

Thanks,
Tys
Answer posted by Alex(support) on Dec 11, 2009 01:09

It is possible to deny event moving in the units view at all:

scheduler.attachEvent("onBeforeDrag", function (event_id, mode, native_event_object){
    return !(mode=="move" && this._mode=="unit");
});

The css class for agenda event is dhx_agenda_area, for tooltip - dhx_tooltip_line


Answer posted by Stanislav (support) on Dec 11, 2009 01:28
There is no css-class template for mentioned elements, but you can use 
            scheduler.templates.year_tooltip
            scheduler.templates.agenda_text
to define how the even't text will look. Code produced by template can have any custom html|styling


Answer posted by Stanislav (support) on Dec 11, 2009 01:31
>>I return false it doesn't roll back the change and the event stays in the column it isn't allowed to be in
There is no simple approach, you can try the next

a) save exesting unit value in onBeforeDrag event
b) in onEventChanged event check is the current view allowed, and restore previously saved one if it is not
c) call updateEvent(id) to correct visual position of event
Answer posted by Tys von Gaza on Dec 11, 2009 09:18
Thanks for the Unit tips, what you suggested should work, I'll try it now.

As for the css on Agenda and Year tooltip, I was hoping to be able to customize those based on the "unit" they belong too.  Ie, blue text in the agenda for calendar 1, red text in the agenda in calendar 2. Ie:

        scheduler.templates.event_class=function(start,end,event) {
            return color_lookup(event.calendar_id);
        }

Thanks,
Tys
Answer posted by Tys von Gaza on Dec 16, 2009 10:55
Could the next version include calls to scheduler.templates.event_class() when it generates the div's for the agenda and year tool tip so those views are consistent with unit/day/week/month?  Below is the code that will do it:

Agenda extension:
G += "<div class='dhx_agenda_line " + scheduler.templates.event_class(H[F].start_date,H[F].end_date,H[F]) + "' event_id='" + H[F].id + "' style='" + (H[F]._text_style || "") + "'><div>" + scheduler.templates.agenda_time(H[F].start_date, H[F].end_date, H[F]) + "</div>";

Year extension:
K += "<div class='dhx_tooltip_line " + scheduler.templates.event_class(H[F].start_date,H[F].end_date,H[F]) + "' event_id='" + H[J].id + "'>";

Thanks,
Tys
Answer posted by Tys von Gaza on Dec 16, 2009 11:08
Oh, that is on the minified version of the file, sorry.  It should be clear what is getting added for the non-minified version.

Tys