Display attribute in client-side javascript tooltip

3 posts, 1 answers
  1. davidp
    davidp avatar
    11 posts
    Member since:
    Jun 2012

    Posted 08 Nov 2012 Link to this post

    I am currently displaying Start, End and Subject in a javascript tooltip but I would like to also display an additional field(PhoneNumber) that is setup as an attribute of the scheduler.  According to the demo at http://demos.telerik.com/aspnet-ajax/scheduler/examples/radtooltip/defaultcs.aspx this should be possible via javascript but I am not sure how to get the attribute so it can be displayed.
    Thanks in advance for any help with this. 
    function OnClientRequestStart(sender, args) {
        args.set_cancel(true);
        var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
        if (tooltip) {
            var element = tooltip.get_targetControl();
            var apt = $find("<%=RadScheduler1.ClientID %>").getAppointmentFromDomElement(element);
            $get("startTime").innerHTML = apt.get_start().format("MM/dd/yyyy HH:mm");
            $get("endTime").innerHTML = apt.get_end().format("MM/dd/yyyy HH:mm");
            $get("descriptionDiv").innerHTML = apt.get_subject();
            tooltip.set_text($get("contentContainer").innerHTML);
        }
    }
    <telerik:RadToolTipManager runat="server" ID="RadToolTipManager1" Width="320" Height="170"
        Animation="None" HideEvent="Default" Text="Loading..." OnAjaxUpdate="RadToolTipManager1_AjaxUpdate" />
         <div style="display: none;">
        <div id="contentContainer">
            Starts on: <span id="startTime"></span>
            <br />
            Ends on: <span id="endTime"></span>
            <hr />
            Description:
            <div id="descriptionDiv">
            </div>                       
        </div>
    </div>
  2. davidp
    davidp avatar
    11 posts
    Member since:
    Jun 2012

    Posted 12 Nov 2012 Link to this post

    Any examples on how to achieve this?  
    PhoneNumber is a customattribute of my scheduler and I would like to display it in a client-side tooltip along with Subject, Start and end.

    Thanks
  3. Answer
    Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 13 Nov 2012 Link to this post

    Hi,

     
    You can set the value of the appropriate custom attribute as in the code below by getting it from the appointment's client object as shown in the code below:

    function OnClientRequestStart(sender, args) {
              args.set_cancel(true);
              var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
              if (tooltip) {
                  var element = tooltip.get_targetControl();
                  var apt = $find("<%=RadScheduler1.ClientID %>").getAppointmentFromDomElement(element);
                  $get("startTime").innerHTML = apt.get_start().format("MM/dd/yyyy HH:mm");
                  $get("endTime").innerHTML = apt.get_end().format("MM/dd/yyyy HH:mm");
                
                  $get("descriptionDiv").innerHTML = apt.get_attributes().getAttribute("PhoneNumber");
                  tooltip.set_text($get("contentContainer").innerHTML);
              }
          }

    Hope this will be helpful.

    Kind 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.
Back to Top