This is a migrated thread and some comments may be shown as answers.

RadScheduler ReadOnly ContextMenu for certain users

4 Answers 214 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Rubihno
Top achievements
Rank 1
Rubihno asked on 16 Oct 2008, 12:01 PM
Hi,

In my radschuder i have implement the example code that i find in this page:

http://demos.telerik.com/ASPNET/Prometheus/Scheduler/Examples/ContextMenu/DefaultCS.aspx

If not use this contextmenu is simple to set the readonly if the users is not administrator..

But how i make to set the readonly on scheduler with the contextmenu?, because use javascript...

example

if row("UserAdmin") = "1" Then

radscheduler1.readonly = true

Else

radscheduler1.readonly = true

End if

How i make if i use the contextmenu click for insert o modifify appointment?
Show or hide the contextmenu...




4 Answers, 1 is accepted

Sort by
0
Rubihno
Top achievements
Rank 1
answered on 21 Oct 2008, 06:34 AM
How can i do?
0
Peter
Telerik team
answered on 21 Oct 2008, 07:14 AM
Hello Rubihno,

First, you need to add the menu item which will disable RadScheduler:
<telerik:RadMenuItem Text="Appointment menu" Enabled="false" /> 
                <telerik:RadMenuItem Text="Delete" Value="Delete" /> 
                <telerik:RadMenuItem Text="Edit" Value="Edit" /> 
                <telerik:RadMenuItem Text="Disable scheduler" Value="Disable" /> 

Then attach to the ItemClick server event of RadMenu (double click the control in design time) and set the ReadOnly property of RadScheduler:

 protected void SchedulerAppointmentContextMenu_ItemClick(object sender, RadMenuEventArgs e)  
        {  
            if(e.Item.Value == "Disable")  
                RadScheduler1.ReadOnly = true;  
        } 

Let us know if you have further questions.


Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Rubihno
Top achievements
Rank 1
answered on 21 Oct 2008, 10:11 AM
Yes this solution is correctly, but the problem is another, i would you like for example:

if  user is administrator show the radcontextmenu for insert or modify, but is not user administrator don't show the radcontextmenu, in practice hide SchedulerTimeSlotContextMenu and SchedulerAppointmentContextMenu.


Example code that i use:

http://demos.telerik.com/ASPNET/Prometheus/Scheduler/Examples/ContextMenu/DefaultCS.aspx
0
Peter
Telerik team
answered on 21 Oct 2008, 02:08 PM

You can use a hidden field to store the current user. Then you can access the hidden field and check the current user on the client. For example:

aspx:
 <asp:HiddenField ID="CurrentUser" runat="server" /> 
    <script type="text/javascript">  
        function checkCurrentUser()   
        {  
            var currentUser = document.getElementById("CurrentUser").value;  
            if(currentUser == "Admin")  
            {  
                alert(currentUser);  
                //use the code from the online example to show the menu   
            }  
              
        }  
        window.onload = checkCurrentUser;  
      
    </script> 

code-behind:
protected void Page_Load(object sender, EventArgs e)  
    {  
        if (!IsPostBack)  
        {  
            string user = "Admin";  
            if (user == "Admin")  
                CurrentUser.Value = "Admin";  
        }          
    } 

This is just an example how to access a value which you have stored on the server at the client side. You will have to adapt this approach as per your need.


Best wishes,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Scheduler
Asked by
Rubihno
Top achievements
Rank 1
Answers by
Rubihno
Top achievements
Rank 1
Peter
Telerik team
Share this question
or