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

Extract ID in AppointmentTemplate

11 Answers 120 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Peterson Mwangi
Top achievements
Rank 1
Peterson Mwangi asked on 10 Nov 2010, 05:52 PM

Hi coders,
I have a <a> tag in the AppointmentTemplate and when a user clicks on the link, I would like to extract the ID of the clicked entry and pass it to a javascript function. This is the code I am trying but it doesn't work. Please let me know how to accomplish this:
 

<AppointmentTemplate>
   <div>
      <a href='#' onclick='openWindow(<%# Eval("ID") %>)'><%# Eval("Subject") %></a>
   </div>
</AppointmentTemplate>


openWindow
is my JavaScript function. Please let me know where I am going wrong.

Thanks, Peterson.

11 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Nov 2010, 03:32 PM
Hi Peterson,

How do you bind RadScheduler? How do you set the DataKeyField property?


Greetings,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Peterson Mwangi
Top achievements
Rank 1
answered on 11 Nov 2010, 03:57 PM
Hi Peter,
I am binding the scheduler programatically in the page_load event, see below: 
calendar.DataSource = dtEventDates;
calendar.DataKeyField = "event_id";
calendar.DataSubjectField = "subject";
calendar.DataStartField = "start_time";
calendar.DataEndField = "end_time";        
          
calendar.DataBind();

Thanks,
Peterson
0
Peter
Telerik team
answered on 16 Nov 2010, 05:31 PM
Hi Peterson,

Can you try the following and let me know if it helps:

<AppointmentTemplate
   <div
      <a href='#' onclick='openWindow(<%# Eval("event_id") %>)'><%# Eval("Subject") %></a
   </div
</AppointmentTemplate>


Sincerely yours,
Peter
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
David
Top achievements
Rank 1
answered on 28 Jan 2011, 11:33 PM
I need help on this one too.  This suggestion did not work.

I am trying to make a link to a form, but i can not get the ID out of the calendar.


 <a href = "TaskView.aspx?id=<%# Eval("ID") %>&a=<%#Eval("Account.Selectedvalue")%>"><%# Eval("Subject") %></a>

I have declared

DataKeyField="TaskKeyID"

but   <%# Eval("TaskKeyID") %>   does not work either

0
Peterson Mwangi
Top achievements
Rank 1
answered on 31 Jan 2011, 07:45 AM
David,
This is how I resolved the issue:
On the RadScheduler, add the client side event handler for OnClientAppointmentClick, as shown below:

OnClientAppointmentClick="onAppointmentClick"

The "onAppointmentClick" is a JavaScript function which is as shown below:

function onAppointmentClick (sender, eventArgs) {
    var id = eventArgs.get_appointment().get_id();
   // rest of the code goes here.
}

Once you have the ID then you can manipulate as you wish.

Hope this helps.

Peterson.

0
David
Top achievements
Rank 1
answered on 31 Jan 2011, 03:38 PM
I am trying to get the link to display in the calendar view before it is ever clicked on so a link shows in the Appointment template.

This should be simple and i am sure my answer will be once i find it.






0
Peterson Mwangi
Top achievements
Rank 1
answered on 31 Jan 2011, 03:52 PM
David,

This should give u a link on the appointment:

<telerik:RadScheduler ID="calendar" runat="server" OnClientAppointmentClick="onAppointmentClick">
    <AppointmentTemplate>
        <div style="cursor:pointer; color:blue;">
            <%# Eval("Subject") %>
        </div>
    </AppointmentTemplate>
</telerik:RadScheduler>

Replace "Subject" with your actual Subject field. There may be other ways to achieve the same, but that was my approach.
0
Peter
Telerik team
answered on 31 Jan 2011, 05:13 PM

Likewise, this will extract the ID in the appointment template:

<AppointmentTemplate>
         * * *
          <%# Eval("ID") %>
      </AppointmentTemplate>


Best wishes,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
David
Top achievements
Rank 1
answered on 31 Jan 2011, 05:47 PM
Look how simple.  i swear i tried that. - If I simplify my link that worked !!

my example even had that in it.

<a href = "TaskView.aspx?id=<%# Eval("ID") %>&a=<%#Eval("AccountNumber")%>"><%# Eval("Subject") %></a>


Now ----

Is there a way to eval  - just plain old fields from the data source that are not mapped to resource controls ?
In my task database there are linked ID numbers. for Service order, Work Order, Quote,  etc. - There is no need to assign them a datasource with a drop down.  These fields are read only in my task table, but if the task is related to another document i want to show a link in the template

for example SONumber  is a field in the data source

<a href = "SOView.aspx?id=<%# Eval("SONumber") %>&a=<%#Eval("AccountNumber")%>"><%# Eval("SONumber") %></a>

When i try to reference that field it says -
Error Message: DataBinding: 'Telerik.Web.UI.Appointment' does not contain a property with the name 'SONumber'.


Thank You !!


0
David
Top achievements
Rank 1
answered on 31 Jan 2011, 06:25 PM
Hey i will answer my own question this time.


I added   
CustomAttributeNames="SOnumber,QuoteNumber,WOnumber" 

to the control declaration -  EZ!  then i can read any of those fields into my template.

This scheduler is going to be a n awesome addition to my project !!!

But i do have one more ....
Can I make parts of that conditional ?  i only want to show the SOnumber link if it has data in it.
It does not like me throwing in <%  IfEval("SONumber") <> "0" Then%>  .....  <% End if %> in the template

<AppointmentTemplate>
         <a href = "taskview.aspx?ID=<%#Eval("ID")%>&a=<%#Eval("AccountNumber")%>"><%#Eval("Account.Text")%> - <%# Eval("Subject") %></a>
 
         <a href = "soview.aspx?ID=<%#Eval("SONumber")%>&a=<%#Eval("AccountNumber")%>"><%#Eval("SoNumber")%></a><br />
       
         <%#Eval("Start", "{0:t}")%> -
         <%#Eval("End", "{0:t}")%><br />
         <%#Eval("Description")%><br />
          
    </AppointmentTemplate>





0
David
Top achievements
Rank 1
answered on 31 Jan 2011, 07:58 PM
Ok so maybe i should think a little more before posting

I got the conditional binding to work like this.

                         
  <%#IIf(Eval("SONumber") <> "0", "<a target = _new href =  ""soview.aspx?id=" & Eval("SoNumber") & "&a=" & Eval("AccountNumber") & """>SO#" & Eval("SoNumber") & "</a><br>", "")%>

                          
                         

Tags
Scheduler
Asked by
Peterson Mwangi
Top achievements
Rank 1
Answers by
Peter
Telerik team
Peterson Mwangi
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or