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

multiuser of scheduler

21 Answers 319 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Hans Jørgen
Top achievements
Rank 1
Hans Jørgen asked on 10 Jul 2008, 09:02 AM
How can I use RADScheduler like the way in outlook exchangeserver.

I want to have different users that not are allow to look in each others scheduler, but administrator should be able to look in all schedulers and insert, update or delete data from user scheduler.

Is it necessary to make a new table in the database to manage that problem or is there an easyer way to do it.

I hope that some can help me.

21 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 10 Jul 2008, 02:44 PM
Hi Hans Jørgen,

You can user Resources as in the Defining Resources online example.


Kind regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 10 Jul 2008, 05:03 PM
Thank you for your answer.

But I don't know exactly in what way how to handle that.

Can I use the same DB table for all users and Admin.

The online example does not give any meaning to me.

I hope you can help me, because I will not be to any trouble for you. 
0
Accepted
Peter
Telerik team
answered on 11 Jul 2008, 08:12 AM

Yes, you can use the same data source for all users and the admin. Notice that in the online example all events come from the AppointmentsDataSource, but the filtering on a user basis is achieved through the select parameter:
<SelectParameters> 
                <asp:ControlParameter Name="UserID" ControlID="UserDropDown" PropertyName="SelectedValue" /> 
</SelectParameters> 

Another approach which you can consider is to use a custom provider and pass a parameter to it. Please, review this KB article for a solution and a demo project: How to pass parameters to a custom database provider


All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 13 Jul 2008, 11:13 AM
thank you for your answer Peter

I've just have one more question.

How can I put default username or userId to scheduler dropdownbox so user don't have to remember it every time a new message is put into the scheduler.

Because when I want to update or delete an apponttment, usermane or userID is automatcly read.

Could it be so that the param you describe in the article 

    (ID#950) How to pass parameters to a custom database provider

automaticly could be used to set the default user in the scheduler, when the user log on.

I hope you understand my question.

Thank you very much.

Have a nice day.
0
Accepted
Peter
Telerik team
answered on 14 Jul 2008, 03:21 PM

Actually, I updated the suggested KB article with your specific scenario in mind. This is a more realistic case than what the KB article orignally demonstrated.

I am not sure if you had a chance to review the modified article. Now you can quit easily adapt it to meet your requirement. Simply, modify the code in Page Load as follows:

protected void Page_Load(object sender, EventArgs e)     
{     
    //Show only appointments for current user     
    MyParam = System.Environment.UserName.ToString();     
           
}    
 

The custom provider class safeguards against non-existent user with the following check in step 5:
if (apt.Resources.GetResourceByType("Teacher") != null)     
         
 



Regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 14 Jul 2008, 05:57 PM
Hi again Peter

Thank you for your answer and KB article it helped me a lot, but I don't think you understand my last question.

What I was asking was, is there an easy way to put username or userID
into the scheduler.

Because when I am inserting a new appontment in the scheduler and tick the green button, the data are inserted in the DB without username or userID and will not be shown in the schedular.

Is it necessary every time to doubleclick the scheduler to go to the advance page to insert new data so I can put in my username or userID.

I hope there wil be an easier way to do that.

To your last answer I use 
    
    MyParam = User.Identity.Name.ToString();

instead of your solution.

I will then allways have the username of the logged in user.

I don't hope I will be in too much trouble for you.

Best regards
Hans Jørgen
0
Accepted
Peter
Telerik team
answered on 15 Jul 2008, 02:31 PM
Hi Hans Jørgen,

You can set the SelectedIndex of the Resource dropdown control in the FormCreated event. Please, try the following code based on the KB article:
 protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)  
    {  
        if ((e.Container.Mode == SchedulerFormMode.AdvancedInsert) || (e.Container.Mode == SchedulerFormMode.AdvancedEdit))  
        {            
            DropDownList userDL = (DropDownList)e.Container.FindControl("Teacher");             
            foreach (Resource r in RadScheduler1.Resources.GetResourcesByType("Teacher"))  
            {  
                if (r.Text == MyParam)  
                    userDL.SelectedIndex = Convert.ToInt16(r.Key);  
            }  
        }  
    } 

Attached is a demo project.

Another approach which you may consider is using Custom Attributes. The difference is that the users will not be displayed in a dropdownlist.

As for getting the user identity, thanks for pointing this out. I realized that with the code I suggested, you get the user logged to the mashine, not the web application.


Regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 16 Jul 2008, 09:03 AM
Hi Peter

The last solution doesn't work the way I want, but never mind.

I have another problem.

When I try to use the solution for defining resources in the example where I can choose to look every useror only a single user.

I take the code I want to use and try it in IIS.

Every time I want to change anything I got the message

    System.Data.EvaluateException: Cannot find column ['-1'] or any other column.

The only thing had move from the code is all the thing that have with the room to do.

I looked over and over again in your code to see if there is any missing thing, but I can't see that.

So I don't now what to do to get it work.

Hope you can help me again.

Thank you very much.
0
Hans Jørgen
Top achievements
Rank 1
answered on 16 Jul 2008, 12:59 PM
Hi again Peter

Where can I find the advanced form of he schedular, so I can edit it to the design that I want?

When I look in help manual under Custom Resources and Attributes I can find a picture of the form but I can't find a way to open and edit it.

Thank you very much

Best regards
Hans Jørgen
0
Accepted
Peter
Telerik team
answered on 16 Jul 2008, 01:40 PM
Hi Hans,

RadScheduler provides AdvancedEditTemplate and AdvancedInsertTemplate which you can use to customize the advanced form, but you have to create everything from scratch as shown in the Templates example.

To avoid reinventing the wheel, we have prepared an example with a step-by-step help guide on how to create the advanced form from a set of user controls. Please, refer to the following resources:

Customizing the Advanced Template along with the help topic

KB article: Sample project of the Customizing the Advanced Template example

As for the previous question, please elaborate what is not working in your case and what you want to achieve. I don't understand what you are trying to do.


All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 16 Jul 2008, 08:14 PM

Hi Peter

Here is my page for the scheduler called kalender.aspx


<%

@ Page Language="C#" MasterPageFile="~/Admin/AdminMaster.master" AutoEventWireup="true" CodeFile="Kalender.aspx.cs" Inherits="_Kalender" Title="Untitled Page" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%
@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>  

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableTheming="True">
</telerik:RadScriptManager>

<div style="width: 100%; height: 100%; position: relative; top: 0px; left: 0px;">
<div style="position: absolute; top: 0px; left: 0px; width: 576px;"> 
<div class="title">
Show schedule for:
<asp:DropDownList runat="server" ID="UserDropDown" AutoPostBack="True" DataSourceID="UsersDataSource" DataTextField="UserName" DataValueField="UserID" OnDataBound="UserDropDown_DataBound"> </asp:DropDownList>
</div>
<telerik:RadScheduler runat="server" ID="RadScheduler1" Width="569px" Skin="Outlook" DataSourceID="AppointmentsDataSource" DataKeyField="ID" DataSubjectField="Emne" DataStartField="Start" DataEndField="Slut" DataRecurrenceField="Gentagelse" DataRecurrenceParentKeyField="GentagelseID" OnAppointmentCreated="RadScheduler1_AppointmentCreated" Culture="Danish (Denmark)" FirstDayOfWeek="Monday" LastDayOfWeek="Sunday" EnableCustomAttributeEditing="True" CustomAttributeNames="Kommentar" > <ResourceTypes>
<telerik:ResourceType KeyField="UserID" Name="Bruger" TextField="UserName" ForeignKeyField="BrugerID" DataSourceID="UsersDataSource" />
</ResourceTypes>
</telerik:RadScheduler>
<sds:SessionDataSource ID="AppointmentsDataSource" runat="server" PrimaryKeyFields="ID" ProviderName="System.Data.OleDb" ConnectionString="<%$ ConnectionStrings:RadSchedulerAccessConnectionString %>" SelectCommand="SELECT * FROM [Aftaler] WHERE [BrugerID] = @UserID OR @UserID = -1"
InsertCommand="INSERT INTO [Aftaler] ([Emne], [Start], [Slut], [BrugerID], [Gentagelse], [GentagelseID]) VALUES (@Subject, @Start, @End , @UserID, @RecurrenceRule, @RecurrenceParentID)"
UpdateCommand="UPDATE [Aftaler] SET [Emne] = @Subject, [Start] = @Start, [Slut] = @End, [BrugerID] = @UserID, [Gentagelse] = @RecurrenceRule, [GentagelseID] = @RecurrenceParentID WHERE (ID = @ID)"
DeleteCommand="DELETE FROM [Aftaler] WHERE [ID] = @ID">
<SelectParameters>
<asp:ControlParameter Name="BrugerID" ControlID="UserDropDown" PropertyName="SelectedValue" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Emne" Type="String" />
<asp:Parameter Name="Start" Type="DateTime" />
<asp:Parameter Name="Slut" Type="DateTime" />
<asp:Parameter Name="BrugerID" Type="Int32" />
<asp:Parameter Name="Gentagelse" Type="String" />
<asp:Parameter Name="GentagelseID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Emne" Type="String" />
<asp:Parameter Name="Start" Type="DateTime" />
<asp:Parameter Name="Slut" Type="DateTime" />
<asp:Parameter Name="BrugerID" Type="Int32" />
<asp:Parameter Name="Gentagelse" Type="String" />
<asp:Parameter Name="GentagelseID" Type="Int32" />
</InsertParameters>
</sds:SessionDataSource>  

<sds:SessionDataSource ID="UsersDataSource" runat="server" DisplayWarning="False" ProviderName="System.Data.OleDb" ConnectionString="<%$ ConnectionStrings:RadSchedulerAccessConnectionString %>" SelectCommand="SELECT * FROM [Bruger]" ClearSessionOnInitialLoad="True" SessionKey="System.Web.UI.Page_UsersDataSource"></sds:SessionDataSource
 </
div>
<div id="kalender">
<telerik:RadCalendar ID="RadCalendar1" runat="server" Font-Names="Verdana" ForeColor="Black" Style="border-color: #ececec" AutoPostBack="True" BorderStyle="Dashed" BorderWidth="1px" CultureInfo="Danish (Denmark)" DayNameFormat="FirstTwoLetters" DefaultCellPadding="1" DefaultCellSpacing="1" EnableMultiSelect="False" FocusedDate="1980-01-01" Font-Size="Small" Height="161px" onselectionchanged="RadCalendar1_SelectionChanged" SelectedDate="2008-07-16" SingleViewHeight="1px" SingleViewWidth="1px" Skin="Outlook" Width="211px">
<SelectedDates>
<telerik:RadDate Date="2008-07-16"></telerik:RadDate>
</SelectedDates>
<CalendarTableStyle BorderStyle="Dashed" BorderWidth="1px" HorizontalAlign="Center" VerticalAlign="Middle" />
<FastNavigationSettings EnableTodayButtonSelection="True" TodayButtonCaption="I dag" />
<TitleStyle Font-Names="Verdana" Font-Size="Medium" />
<HeaderStyle BackColor="White" Font-Names="Verdana" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:RadCalendar>
</div>
</
div>
</
asp:Content>


And the code behind file 

using

System;
using System.Data;
using System.Collections;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using Telerik.Web.UI.Calendar;

public

partial class _Kalender : MyPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {        
//SelectInitialProperty();
            RadCalendar1.SelectedDate = RadScheduler1.SelectedDate;
            RadCalendar1.FocusedDate = RadScheduler1.SelectedDate;
            RadScheduler1.SelectedView =
SchedulerViewType.DayView;
        }

        MyParam = User.Identity.Name.ToString(); 
    }

    protected void RadScheduler1_FormCreated(object sender, 
    SchedulerFormCreatedEventArgs e)
    {
        if ((e.Container.Mode == SchedulerFormMode.AdvancedInsert) || (e.Container.Mode == SchedulerFormMode.AdvancedEdit))
        {
            DropDownList userDL = (DropDownList)e.Container.FindControl("Bruger");
            foreach (Resource r in RadScheduler1.Resources.GetResourcesByType("Bruger"))
            {    
                if (r.Text == MyParam)
                    userDL.SelectedIndex =
Convert.ToInt16(r.Key);
            }
        }    
    }

    protected void RadCalendar1_SelectionChanged(object sender, 
    SelectedDatesEventArgs e)
    {
        if (RadCalendar1.SelectedDates.Count > 0)
        {    
            RadScheduler1.SelectedDate = RadCalendar1.SelectedDate;
        }
    }

    protected void RadScheduler1_AppointmentCreated(object sender, 
    AppointmentCreatedEventArgs e)
    {
         foreach (Resource resource in e.Appointment.Resources)
        {
            if (resource.Type == "Bruger")
            {
                e.Appointment.CssClass = resource.Text.Replace(
' ', '_');
            }
        }
    }

    protected void UserDropDown_DataBound(object sender, EventArgs e)
    {
        UserDropDown.Items.Insert(0,
new ListItem("Alle brugere", "-1"));
    }
}

When  I run it in visual studio 2008 and try to change date or change to weeklook or something else I get the error messages show below

Exception Details: System.Data.EvaluateException: Cannot find column ['-1'].

foreach (DataRow row in mergeResult.Select(GetCurrentSelectFilterExpression()))

Source File: n:\Safe-and-secure\App_Code\SessionDataSource.cs    Line: 483


it is not onle column ['-1'] but all columns and I dont know where to find the error.

What I want is to have the possibility to view one or all user in the scheduler as shown in the example
 http://www.telerik.com/demos/aspnet/prometheus/Scheduler/Examples/Resources/DefaultCS.aspx

I hope that this is enough to understand my question.

Best regards
Hans Jørgen

0
Accepted
Peter
Telerik team
answered on 17 Jul 2008, 10:57 AM
Hi Hans Jørgen,

The problem seems to be coming from the SessionDataSource.cs class. This is strange since the Defining Resources example works without problems. 

I noticed that you are using the same SessionDataSource as in the example. Do you plan to stay with this type of data source or do you use it only for testing purposes? Can you replace the datasource for the users dropdownlist and test again. Just make sure you define insert, update, delete and select statements for your new datasource. Let us know of the results.


All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 18 Jul 2008, 11:39 AM
Hi again Peter

Now I have change the .aspx file and remove connection to the session file, because every time I try med an access DB it went wrong.

So here is my new . aspx file which is working as I wanted except as the earlier question about automatic default name in scheduler when I what to insert an apointment like the way it is when I want to edit an appointment.

I hope this code will help you.

<%

@ Page Language="C#" MasterPageFile="~/Admin/AdminMaster.master" AutoEventWireup="true" CodeFile="Kalender.aspx.cs" Inherits="_Kalender" Title="Untitled Page" %>

<%

@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"
EnableTheming="True">
</telerik:RadScriptManager>
    <div style="width: 100%; height: 100%; position: relative; top: 0px; left: 0px;">
        <asp:SqlDataSource ID="UsersDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:RadSchedulerConnectionString %>"
            
SelectCommand="SELECT * FROM [Bruger]" ProviderName="
            <%$ConnectionStrings:RadSchedulerConnectionString.ProviderName %">
        </
asp:SqlDataSource>
    <div class="title">
    Vis aftaler for : 
    <asp:DropDownList runat="server" ID="UserDropDown" AutoPostBack="True"
        
DataSourceID="UsersDataSource" DataTextField="UserName"
        
DataValueField="UserID" OnDataBound="UserDropDown_DataBound">
    </asp:DropDownList>
    </div>
    
<telerik:RadScheduler ID="RadScheduler1" 
        runat
="server"  Width="569px" Skin="Outlook" Culture="Danish (Denmark)" 
        FirstDayOfWeek="Monday" LastDayOfWeek="Sunday" DataEndField="Slut" 
        DataKeyField
="ID" DataRecurrenceField="Gentagelse" 
        DataRecurrenceParentKeyField
="GentagelseID" 
        DataSourceID
="AppointmentsDataSource" DataStartField="Start" 
        DataSubjectField
="Emne" 
        OnAppointmentCreated
="RadScheduler1_AppointmentCreated" 
        EnableCustomAttributeEditing
="True" CustomAttributeNames="Kommentar">
    <ResourceTypes>
    <telerik:ResourceType KeyField="UserID" Name="Bruger" TextField="UserName"     
        ForeignKeyField
="BrugerID" DataSourceID="UsersDataSource" />
    </ResourceTypes>
    <MonthView HeaderDateFormat="MMMM yyyy" />   
    
<DayView HeaderDateFormat="dddd d MMMM yyyy" />
    <WeekView ColumnHeaderDateFormat="ddd d" />
    </telerik:RadScheduler>    
    <asp:SqlDataSource ID="AppointmentsDataSource" runat="server"
    
ProviderName="<%$ConnectionStrings:RadSchedulerConnectionString.ProviderName %>"
    ConnectionString="<%$ ConnectionStrings:RadSchedulerConnectionString %>"     
    DeleteCommand
="DELETE FROM [Aftaler] WHERE [ID] = @ID"
    
InsertCommand="INSERT INTO [Aftaler] ([Emne], [Start], [Slut], [BrugerID], 
    [Gentagelse], [GentagelseID], [Kommentar]) VALUES (@Emne, @Start, @Slut, 
    @BrugerID, @Gentagelse, @GentagelseID, @Kommentar)"
 
    SelectCommand
="SELECT * FROM [Aftaler] WHERE [BrugerID] = @UserID OR 
    @UserID = -1"
 
    
UpdateCommand="UPDATE [Aftaler] SET [Emne] = @Emne, [Start] = @Start, [Slut] = 
    @Slut, [BrugerID] = @BrugerID, [Gentagelse] = @Gentagelse, [GentagelseID] = 
    @GentagelseID, [Kommentar] = @Kommentar WHERE [ID] = @ID ">
    <SelectParameters>    
    
<asp:ControlParameter Name="UserID" ControlID="UserDropDown"     
    PropertyName
="SelectedValue" />
    </SelectParameters>
    <DeleteParameters>
        <asp:Parameter Name="ID" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="Emne" Type="String" />
        <asp:Parameter Name="Start" Type="DateTime" />
        <asp:Parameter Name="Slut" Type="DateTime" />
        <asp:Parameter Name="BrugerID" Type="Int32" />
        <asp:Parameter Name="Gentagelse" Type="String" />
        <asp:Parameter Name="GentagelseID" Type="Int32" />
        <asp:Parameter Name="Kommentar" Type="String" />
        <asp:Parameter Name="ID" Type="Int32" />
    </UpdateParameters>
    <InsertParameters>
        <asp:Parameter Name="Emne" Type="String" />    
        <asp:Parameter Name="Start" Type="DateTime" />
        <asp:Parameter Name="Slut" Type="DateTime" />    
        <asp:Parameter Name="BrugerID" Type="Int32" />
        <asp:Parameter Name="Gentagelse" Type="String" />
        <asp:Parameter Name="GentagelseID" Type="Int32" />
        <asp:Parameter Name="Kommentar" Type="String" />
    </InsertParameters>
    </asp:SqlDataSource>
    <div id="kalender">
    
<telerik:RadCalendar ID="RadCalendar1" runat="server" Font-Names="Verdana"
    ForeColor="Black" Style="border-color: #ececec" AutoPostBack="True" 
    BorderStyle
="Dashed" BorderWidth="1px" CultureInfo="Danish (Denmark)" 
    DayNameFormat
="FirstTwoLetters" DefaultCellPadding="1" DefaultCellSpacing="1" 
    EnableMultiSelect
="False" FocusedDate="1980-01-01" Font-Size="Small" 
    Height
="161px" onselectionchanged="RadCalendar1_SelectionChanged" 
    SelectedDate
="2008-07-16" SingleViewHeight="1px" SingleViewWidth="1px" 
    Skin
="Outlook" Width="211px">
    <SelectedDates>
    <telerik:RadDate Date="2008-07-16"></telerik:RadDate>
    
</SelectedDates>
    <CalendarTableStyle BorderStyle="Dashed" BorderWidth="1px" 
    HorizontalAlign
="Center" VerticalAlign="Middle" />
    <FastNavigationSettings EnableTodayButtonSelection="True" 
    TodayButtonCaption
="I dag" />
    <TitleStyle Font-Names="Verdana" Font-Size="Medium" />
    <HeaderStyle BackColor="White" Font-Names="Verdana" Font-Size="Small" 
    HorizontalAlign
="Center" VerticalAlign="Middle" />
    </telerik:RadCalendar>
    </
div>
    </
div>
</
asp:Content>



I hope to get a solution later on my problem, but thanks for now and for your help, it hasbeen so nice to get so prossional help.

Have a nice weekend.

Regards
Hans Jørgen

0
Peter
Telerik team
answered on 22 Jul 2008, 02:54 PM
Hello Hans,

We will be happy to help you again, but I need to clarify a couple of points first.

First, were you able to get the desired functionality when editing an appointment?

Second, you would like to have the same functionality when inserting and appointment. Is this the case?

If the answer to both questions is yes, then you don't need to modify your code additionally. Please, consider the following code segment which is part of your solution:
protected void RadScheduler1_FormCreated(object sender,   
    SchedulerFormCreatedEventArgs e)  
    {  
        if ((e.Container.Mode == SchedulerFormMode.AdvancedInsert) || (e.Container.Mode == SchedulerFormMode.AdvancedEdit))  
        {  
            DropDownList userDL = (DropDownList)e.Container.FindControl("Bruger");  
            foreach (Resource r in RadScheduler1.Resources.GetResourcesByType("Bruger"))  
            {      
                if (r.Text == MyParam)  
                    userDL.SelectedIndex = Convert.ToInt16(r.Key);  
            }  
        }      
    }   
 

Note, that we check if the advanced form's mode is AdvancedInsert or AdvancedEdit. In both cases we execute the same logic.

Let me know if I am missing something.

Kind regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 22 Jul 2008, 06:14 PM
Hi again Peter

To your first question I get the desired functionality without using any special code because the user already marked in the dropdownbox in the advanced editform.

To the second question I would like to have the possibility to automatic insert the user in the userID in DB when I tick the green button on the normal schedular form. Even when I go to the avancedInsertform I have to manually set the user, so it will appear in the DB.

The RadScheduler1_FormCreated  code is never used.

I have treid many times with debug , but the program never comes to that piece code.

I hope this will help you a little bit more to my question.

Thank you very much.

Best regards
Hans Jørgen
0
Peter
Telerik team
answered on 24 Jul 2008, 02:00 PM

Hello Hans,

Please, make sure you attach the event handler for FormCreated:
 <telerik:RadScheduler ID="RadScheduler1" runat="server" 
            onformcreated="RadScheduler1_FormCreated"

Did this help?

Best wishes,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 24 Jul 2008, 06:07 PM
Hello again Peter

It helped me when I go to the advanced insert or edit page.

But where can I find the code for normal insert?

When I hold the mouse over the green button I can see a link in the stausbar that looks like this

        Javascript:_doPostBack('ctl00$ContentPlaceHolder1$RadScheduler1$ctl92$insert',")

That doesn,t say much to me.

I would like to automaticly inset the userID in the DB when I push the green button together with the text from the scheduler.

Hope this would help you to my problem

Thanks again Peter

Best regards
Hans Jørgen
0
Peter
Telerik team
answered on 28 Jul 2008, 08:42 AM
Hello Hans,

Please, try the following and let us know if this is what you need:
protected void RadScheduler1_FormCreated(object sender, Telerik.Web.UI.SchedulerFormCreatedEventArgs e)  
    {  
        if (e.Container.Mode = Telerik.Web.UI.SchedulerFormMode.Insert)  
        {  
            Response.Write("This is normal insert");  
        }  
    } 


All the best,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hans Jørgen
Top achievements
Rank 1
answered on 28 Jul 2008, 03:43 PM
Hi Peter

Some comments to your code:


protected void RadScheduler1_FormCreated(object sender, Telerik.Web.UI.SchedulerFormCreatedEventArgs e)  
if (e.Container.Mode = Telerik.Web.UI.SchedulerFormMode.Insert)   
    {      
        Here I would like to insert UserID into the DB         

        Response.Write("This is normal insert");   
    }


I hope my answer will help you to my problem.

Thanks

regards
Hans Jørgen
0
Peter
Telerik team
answered on 29 Jul 2008, 12:06 PM
Hi Hans,

If I understand you corectly, you want to have a preselected resource when inserting an appointment without going in advanced insert mode. You can achive this with the following code:

protected void RadScheduler1_FormCreated(object sender, Telerik.Web.UI.SchedulerFormCreatedEventArgs e)  
    {  
        ViewState["InsertType"] = e.Container.Mode.ToString();  
    }  
      
    protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)  
    {  
        if (ViewState["InsertType"].ToString() != "AdvancedInsert")  
        e.Appointment.Resources.Add(new Resource("Bruger", 1"A"));          
    } 

Note, that instead of FormCreated, the code above uses AppointmentInsert to insert UserID into the DB by setting dynamically a resource to the appointment. FormCreated is used to keep track of the insert type (whether through the advanced form or the inline form). This way you can still go in advanced form and change the selected resource.

Please, let us know if we managed to bring this case to completion or you have further questions. We will be happy to help you further if needed.

Best wishes,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hans Jørgen
Top achievements
Rank 1
answered on 29 Jul 2008, 08:17 PM
Hi again Peter

Now I'm happy, because it works like I want it to. I did a little change to your code and her it is:

protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)

     ViewState[
"InsertType"] = e.Container.Mode.ToString();
     
        if
((e.Container.Mode == SchedulerFormMode.AdvancedInsert) ||
             (e.Container.Mode ==
SchedulerFormMode.AdvancedEdit))
        {
                DropDownList userDL = (DropDownList)e.Container.FindControl("Bruger");
            
foreach (Resource r in RadScheduler1.Resources.GetResourcesByType("Bruger"))
            {
                    if (r.Text.ToLower() == MyParam)
                    userDL.SelectedIndex =
Convert.ToInt16(r.Key);
            }
        }
}

protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
{
        if (ViewState["InsertType"].ToString() != "AdvancedInsert")
        {
            foreach (Resource r in RadScheduler1.Resources.GetResourcesByType("Bruger"))
            {
                    if (r.Text.ToLower() == MyParam)
                    {
                            e.Appointment.Resources.Add(
new Resource("Bruger", r.Key, "A"));
                    }
              }
          }
}
 
I would like to thank very much once again for your great help.

Have a very nice summer.

Best regards
Hans Jørgen

Tags
Scheduler
Asked by
Hans Jørgen
Top achievements
Rank 1
Answers by
Peter
Telerik team
Hans Jørgen
Top achievements
Rank 1
Share this question
or