search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Disabling the click event for creating new events

Asked by Tom
13 years ago.
Hi Dan,

Is it possible to disable the create event depending on who is viewing the control.

eg. There are 2 users A & B
A has permission to create a new event
B doesn't have permission to create event.

I can retrieve the details of who can create an event no problem, its just the ability to disable the create event I am having trouble with.

Thanks

Tom
Comment posted by Dan Letecky
13 years ago.
The easiest solution is to set TimeRangeSelectedHandling to "Disabled" for the people who don't have the permissions.

If you are using context menus and still want to permit other operations, you can create two menus and assign ContextMenuSelectionID according to your rules.
Comment posted by Tom
13 years ago.
Cheers Dan,

Another question, is it possible to disable a row? I have tried the same method but keep on disabling the whole control.

Thanks

Tom
Comment posted by Dan Letecky
13 years ago.
Unfortunately, it's not possible to disable a row.

I'm trying to find a solution...

I can't imagine any elegant way to prevent the selection (moreove, I think that would be confusing for the users) but it would be possible to customize the selection handling:

1. If you are firing the event immediately after the selection is finished (i.e. using TimeRangeSelected event) you can handle your rules on the server side. In the TimeRangeSelected handler you can call Update("details about why the action was denied"). The details will be passed to AfterRenderJavaScript.

2. If you are using the selection context menu you would need to assign the context menu dynamically depending on the selection details. I could add a SelectionRightClick event where you could decide what to do: open a standard context menu, open a custom context menu, do another action or do nothing.

What would you prefer?
Comment posted by Tom
13 years ago.

QUOTE:
I can't imagine any elegant way to prevent the selection (moreove, I think that would be confusing for the users) but it would be possible to customize the selection handling:


We are currently changing the background colour of this so people know it is not useable but they are still able to create a new event here.

--------------------------------------------------------------------------------------------------------------

QUOTE:
1. If you are firing the event immediately after the selection is finished (i.e. using TimeRangeSelected event) you can handle your rules on the server side. In the TimeRangeSelected handler you can call Update("details about

Would it be possible to do the above one.
Comment posted by Dan Letecky
13 years ago.
The option #1 is already available. Beyond coloring the forbidden areas you would need to do the following (schematically) in the TimeRangeSelected handler:

if (allowed) {
createANewEventInTheDB(start, end);
DayPilotScheduler1.DataBind();
DayPilotScheduler1.Update();
}
else {
Hashtable response = new Hashtable();
response["status"] = "not-allowed";
response["message"] = "It's not allowed to create a new event in this area";
DayPilotScheduler1.Update(response);
}
Then use the following JavaScript handler for AfterRenderJavaScript:
function afterRender(data) {
if (data) {
if (data.status == 'not-allowed') {
showMessage(data.message);
}
}
}
I've used a Hashtable in the example to demonstrate that you can send a structure back instead of a simple string.


Could that work for you?
This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.