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

Bind Rad Scheduler To two Different Datasources(SQL)

9 Answers 131 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Nikola
Top achievements
Rank 2
Nikola asked on 22 Nov 2012, 03:42 PM
Heey guys

I have  a question is it possible to bind tow sql sources in one RadScheudler ?  An example with sql would really help  

My code 
<%@ Page Title="" Language="C#" MasterPageFile="~/ABBMaster.Master" AutoEventWireup="true" CodeBehind="UserScheduler.aspx.cs" Inherits="HolidayTracker.User.UserScheduler" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="MainRegionContentPlaceHolder" runat="server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function Export(sender, e) {
                $find("<%= RadAjaxManager1.ClientID %>").__doPostBack(sender.name, "");
            }
 
        </script>
    </telerik:RadCodeBlock>
    <style type="text/css">
        .RadScheduler .rsExportButton {
            position: absolute;
            bottom: 0;
            right: 0;
            border: 0;
            height: 24px;
            width: 24px;
            background: url('exportButtonli.gif') no-repeat center center;
        }
 
        .RadScheduler .rsAllDayRow .rsExportButton {
            right: 20px;
            height: 16px;
            width: 16px;
            bottom: 20px;
            background: url('exportButton.gif');
        }
 
        #Label1Panel {
            display: inline !important;
        }
 
        .lblError {
            background: #CC0000;
            border: 1px solid darkred;
            color: white;
            font: bold 16px "Segoe UI", Arial, sans-serif;
            vertical-align: middle;
            display: none;
            height: 30px;
            line-height: 28px;
            position: absolute;
            padding-left: 5px;
            width: 743px;
            z-index: 1001;
            cursor: pointer;
            opacity: 0.9;
            -moz-opacity: 0.9;
            filter: alpha(opacity=90);
        }
 
        .rsCustomAppointmentContainer div {
            width: 100% !important;
        }
 
        .rsCustomAppointmentContainer h2 {
            overflow: hidden !important;
            white-space: nowrap !important;
            text-overflow: ellipsis !important;
        }
    </style>
 
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    <telerik:AjaxUpdatedControl ControlID="Label1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <asp:Label ID="Label1" runat="server" CssClass="lblError"></asp:Label>
    <div style="margin: 5px 0">
        <asp:ImageButton runat="server" ID="Button2" ImageUrl="exportButton.gif" AlternateText="Export All to Lotus Notes"
            OnClientClick="Export(this, event); return false;" OnClick="Button2_Click"></asp:ImageButton>
    </div>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" InitialDelayTime="200">
    </telerik:RadAjaxLoadingPanel>
    <div class="exampleContainer">
        <telerik:RadScheduler runat="server" ID="RadScheduler1" Width="750px"
            DayStartTime="07:00:00" DayEndTime="18:00:00" DataSourceID="SqlDataSource1"
            DataKeyField="VacationDayId" DataSubjectField="Title" DataStartField="FromDate" DataEndField="ToDate"
            OnAppointmentUpdate="RadScheduler1_AppointmentUpdate"
            OnAppointmentInsert="RadScheduler1_AppointmentInsert"
            OnRecurrenceExceptionCreated="RadScheduler1_RecurrenceExceptionCreated">
            <AdvancedForm Modal="true"></AdvancedForm>
            <TimelineView UserSelectable="false"></TimelineView>
            <TimeSlotContextMenuSettings EnableDefault="true"></TimeSlotContextMenuSettings>
            <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings>
        </telerik:RadScheduler>
    </div>
 
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=HolidayTrackerEntities" DefaultContainerName="HolidayTrackerEntities" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EntitySetName="HtVacationDays"></asp:EntityDataSource>
 
 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HolidayTrackerConnectionString %>" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [HtVacationDay]" DeleteCommand="DELETE FROM [HtVacationDay] WHERE [VacationDayId] = @original_VacationDayId" InsertCommand="INSERT INTO [HtVacationDay] ([Title], [FromDate], [UserId], [Hours], [ToDate], [RecurrenceRule], [RecurrenceRuleID]) VALUES (@Title, @FromDate, @UserId, @Hours, @ToDate, @RecurrenceRule, @RecurrenceRuleID)" UpdateCommand="UPDATE [HtVacationDay] SET [Title] = @Title, [FromDate] = @FromDate, [UserId] = @UserId, [Hours] = @Hours, [ToDate] = @ToDate, [RecurrenceRule] = @RecurrenceRule, [RecurrenceRuleID] = @RecurrenceRuleID WHERE [VacationDayId] = @original_VacationDayId">
        <DeleteParameters>
            <asp:Parameter Name="original_VacationDayId" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="FromDate" Type="DateTime" />
            <asp:Parameter Name="UserId" Type="Int32" />
            <asp:Parameter Name="Hours" Type="Double" />
            <asp:Parameter Name="ToDate" Type="DateTime" />
            <asp:Parameter Name="RecurrenceRule" Type="String" />
            <asp:Parameter Name="RecurrenceRuleID" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="FromDate" Type="DateTime" />
            <asp:Parameter Name="UserId" Type="Int32" />
            <asp:Parameter Name="Hours" Type="Double" />
            <asp:Parameter Name="ToDate" Type="DateTime" />
            <asp:Parameter Name="RecurrenceRule" Type="String" />
            <asp:Parameter Name="RecurrenceRuleID" Type="String" />
            <asp:Parameter Name="original_VacationDayId" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
   
</asp:Content>

Thanks for help and fast answer

9 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 23 Nov 2012, 06:49 AM
Hi Nikola,

 
Binding RadScheduler to two DataSources at the same time is a not supported scenario. If you want to change them somehow you can achieve it in the code behind as it is explained in the Using The Data Source Property help article.

Hope this will be helpful.

Regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Nikola
Top achievements
Rank 2
answered on 23 Nov 2012, 08:45 AM
Heey

 but then i got another question how can i display some special  days like public vacation but the user can not edit them ? 

Thanks for help and fast answer 
0
Princy
Top achievements
Rank 2
answered on 23 Nov 2012, 09:29 AM
Hi Nikola,

You can disable the editing of the appointments in the special days using the AppointmentCreated event of RadScheduler as follows.

C#:
protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
{
    foreach (DateTime dt in SpecialDays)
    {
        if (DateTime.Compare(e.Appointment.Start.Date, dt) == 0)
        {
            e.Appointment.AllowEdit = false;
        }
    }
}

Hope this helps.

Regards,
Princy.
0
Nikola
Top achievements
Rank 2
answered on 23 Nov 2012, 09:44 AM
heey 

thanks for the answer but i found this awesome link form you !! 
Setting special days or time slots in RadScheduler
http://www.telerik.com/support/kb/aspnet-ajax/scheduler/setting-special-days-or-time-slots-in-radscheduler.aspx




show me every thing that i want but one question how can i make this method dynamic  

private readonly DateTime[] SpecialDays = new DateTime[] { new DateTime(2012, 12, 24), new DateTime(2012, 12, 25), new DateTime(2012, 12, 26), new DateTime(2012, 12, 27), new DateTime(2012, 12, 28), new DateTime(2012, 12, 29), new DateTime(2012, 12, 30) };

it should load from dates directly from the DB 
0
Plamen
Telerik team
answered on 23 Nov 2012, 11:00 AM
Hi Nikola,

 
You can refer to our Customizing Time Slots demo where similar functionality have been implemented. 

Regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Nikola
Top achievements
Rank 2
answered on 23 Nov 2012, 01:11 PM
heey

thanks for your input  

is there not a real solution and not just workaround  for my question ? 

thanks for help 
0
Plamen
Telerik team
answered on 26 Nov 2012, 07:12 AM
Hi Nikola,

 
As far as I understand the functionality you are trying to implement is to bind the "special days" or "slots" from a DB-and that is exactly what is implemented in the Customized Time slots demo( even with additional ability to add and remove such time slots  from the time slot context menu).

 If the scenario you are trying to achieve is somehow different please let us know how exactly so we could be more helpful.

Greetings,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Nikola
Top achievements
Rank 2
answered on 27 Nov 2012, 10:06 AM
Heey 

Here is the solution i got it by my self
Code behind in UserScheduler 
private List<DateTime> specialDays;
      //private readonly DateTime[] SpecialDays = new DateTime[] { new DateTime(2012, 12, 24), new DateTime(2012, 12, 25), new DateTime(2012, 12, 26), new DateTime(2012, 12, 27), new DateTime(2012, 12, 28), new DateTime(2012, 12, 29), new DateTime(2012, 12, 30), new DateTime(2012, 12, 31), new DateTime(2012, 1, 1), new DateTime(2012, 1, 2), };
      private List<DateTime> SpecialDays
      {
          get
          {
              if (specialDays == null)
              {
                  specialDays = PublicVacation.SpecialDays();
              }
              return specialDays;
          }
      }
  

In my Model (PublicVacation.cs)

public static List<DateTime> SpecialDays()
        {
            List<DateTime> result = new List<DateTime>();
            HolidayTrackerEntities ctx = HtEntityFactory.Context;
            foreach (PublicVacation pv in ctx.PublicVacations)
            {
                if (string.IsNullOrEmpty(pv.RecurrenceRule))
                {
                    DateTime StartDate = pv.FromDate.Value;
                    DateTime EndDate = pv.ToDate.Value;
 
                    while (StartDate < EndDate)
                    {
                        result.Add(StartDate);
                        StartDate = StartDate.AddDays(1);
                    }
                }
 
return result;


Have Fun 
0
Plamen
Telerik team
answered on 28 Nov 2012, 09:58 AM
Hello Nikola,

 
Thank you for sharing the solution of your scenario with the community and for your concern with RadControls.

Regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Nikola
Top achievements
Rank 2
Answers by
Plamen
Telerik team
Nikola
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or