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

How to disable/enable button in Appointment Template based on database field

2 Answers 163 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Sandhya
Top achievements
Rank 1
Sandhya asked on 19 Apr 2012, 11:27 AM
Hello,

Need Help!I am using RadScheduler for displaying appointments.I have 2 Issues.

Issue 1 :
I am using DB2 database to display information for appointments.
I have a requirement to enable/disable button in each appointment based on database feild while the appointments are being loaded.
My Database field has either 'Y' or 'N'. If field is 'Y',disable the button.If field is 'N',enable the button on each appointment.
I added Button in Appointment Template along with other fields.

I referred this forum http://www.telerik.com/community/forums/aspnet-ajax/scheduler/i-wonder-if-it-is-not-available-in-rad-scheduler.aspx but couldn't helped me.

Code for the Reference:
<telerik:RadScheduler ID="RadScheduler1" runat="server" DataEndField="CAETIME" DataKeyField="CAPPID"
                DataStartField="CASTIME" DataSubjectField="CAPVISIT" OnAppointmentCreated="RadScheduler1_AppointmentCreated"
                OnDataBound="RadScheduler1_DataBound" CustomAttributeNames="CACLIENT,CAAREP">
                <AppointmentTemplate>
                    <asp:Label ID="lblStart" runat="Server" Text='<%#Eval("Start")%>'></asp:Label>
                    <asp:Label ID="lblHyphen" runat="Server" Text='-'></asp:Label>
                    <asp:Label ID="lblEnd" runat="Server" Text='<%#Eval("End") %>'></asp:Label><br />
                    <b>Subject : </b>
                    <asp:Label ID="lblSub" runat="server" Text='<%#Eval("Subject")%>' /><br />
                    <b>Client : </b>
                    <asp:Label ID="lblClient" runat="Server" Text='<%#Eval("CACLIENT")%>'></asp:Label><br />
                    <asp:Button ID="Button1" runat="server" Text="Action Report" />
                </AppointmentTemplate>
            </telerik:RadScheduler>

Button1 should be disable/enable based on the field CAAREP(Action Report) which was include in CustomAttributeNames.

Issue 2:
My StartField and EndField are in DateTime format which are coming from database. I want to display only Time on Appointments.I tried the below way but it is displaying last appointment times on all the appointments.It is considering last appointment times.
public string stime, etime;
  DateTime dts, dte;
 
 using (DB2Command cmd = new DB2Command(viewAppT, conn))
           {
               cmd.CommandType = CommandType.Text;
               DB2DataAdapter adp = new DB2DataAdapter(cmd);
               DataSet dsAppt = new DataSet();
               adp.Fill(dsAppt);
               RadScheduler1.DataSource = dsAppt;
               DataView dv = dsAppt.Tables[0].DefaultView;
 
               RadScheduler1.DataSource = dv;
               RadScheduler1.DataBind();
               for (int i = 0; i < dv.Table.Rows.Count; i++)
               {
                   dts = Convert.ToDateTime(dv.Table.Rows[i]["CASTIME"]);
                   dte = Convert.ToDateTime(dv.Table.Rows[i]["CAETIME"]);
                   stime = dts.ToShortTimeString();
                   etime = dte.ToShortTimeString();
               }
                
                                            
               RadScheduler1.SelectedView = SchedulerViewType.MonthView;
               RadScheduler1.SelectedDate = Convert.ToDateTime(dv.Table.Rows[0]["CAETIME"]);
               RadScheduler1.Visible = true;
           }
<telerik:RadScheduler ID="RadScheduler1" runat="server" DataEndField="CAETIME" DataKeyField="CAPPID"
               DataStartField="CASTIME" DataSubjectField="CAPVISIT" OnAppointmentCreated="RadScheduler1_AppointmentCreated"
               OnDataBound="RadScheduler1_DataBound" CustomAttributeNames="CACLIENT,CAAREP">
               <AppointmentTemplate>
                  <%-- <asp:Label ID="lblStart" runat="Server" Text='<%#Eval("Start")%>'></asp:Label>--%>
                   <asp:Label ID="Label1" runat="Server" Text='<%# stime %>'></asp:Label>
                   <asp:Label ID="lblHyphen" runat="Server" Text='-'></asp:Label>
                  <%-- <asp:Label ID="lblEnd" runat="Server" Text='<%#Eval("End") %>'></asp:Label><br />--%>
                     <asp:Label ID="Label2" runat="Server" Text='<%# etime %>'></asp:Label>
                   <b>Subject : </b>
                   <asp:Label ID="lblSub" runat="server" Text='<%#Eval("Subject")%>' /><br />
                   <b>Client : </b>
                   <asp:Label ID="lblClient" runat="Server" Text='<%#Eval("CACLIENT")%>'></asp:Label><br />
                   <asp:Button ID="Button1" runat="server" Text="Action Report" />
               </AppointmentTemplate>
           </telerik:RadScheduler>

Could someone Please provide me solution for this issue.

Many Thanks,
Sandhya.

2 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 24 Apr 2012, 08:17 AM
Hello Sandhya,

Attached is a sample project  which demonstrates how to achieve the desired manipulation with appointment template.

You could also refer to the code of the following online demo for more information on accessing elements inside an appointment template: http://demos.telerik.com/aspnet-ajax/scheduler/examples/customizeappointment/defaultcs.aspx.

All the best,
Ivana
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
Sandhya
Top achievements
Rank 1
answered on 24 Apr 2012, 10:13 AM
Thanks Alot for your reply Ivana! This solved my issues.
Tags
Scheduler
Asked by
Sandhya
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Sandhya
Top achievements
Rank 1
Share this question
or