【问题标题】:Tooltip in FullCalendarFullCalendar 中的工具提示
【发布时间】:2018-07-27 06:19:00
【问题描述】:

我正在尝试在我的日历中制作一个工具提示, 日历工作正常,但我想显示患者的更多详细信息,例如 鼠标悬停时患者的描述。我不知道该怎么做? 有人能帮帮我吗?

参考链接(https://fullcalendar.io/)

这就是我所做的

 <div id='calendar'></div>

Javascript(ajax)

数据取自动态

<link href='jscss/fullcalendar.min.css' rel='stylesheet' />
    <link href='jscss/fullcalendar.print.min.css' rel='stylesheet' media='print' />
    <script src='lib/moment.min.js'></script>
    <script src='lib/jquery.min.js'></script>
    <script src='jscss/fullcalendar.min.js'></script>
    <script src='jscss/locale-all.js'></script>
        <script>
            $(document).ready(function () {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "Scheduler.aspx/GetEvents",
                    dataType: "json",
                    success: function (data) {
                        var initialLocaleCode = 'en';
                        var myJsonString = data.d;
                        $('#calendar').fullCalendar({
                            header: {
                                left: 'prev,next today',
                                center: 'title',
                                right: 'month,agendaWeek,agendaDay,listMonth'
                            },
                            defaultDate: new Date(),
                            locale: initialLocaleCode,
                            buttonIcons: false, // show the prev/next text
                            weekNumbers: true,
                            navLinks: true, // can click day/week names to navigate views
                            editable: true,
                            eventLimit: true, // allow "more" link when too many events   
                            events: data.d
                        });
                    }
                });
            });

    </script>

方法

    [WebMethod]
    public static IList GetEvents()
    {
        clsDBOperation obj = new clsDBOperation();
        DataTable dt1 = obj.GetDataTable("SELECT con.EDate as EDate ,  con.pfname , COUNT(*) OVER (PARTITION BY CAST(con.AppDate AS DATE)) Appointment, con.AppDate as Date, CAST(con.AppTime AS Time(0)) Time from Consultation as con inner join DoctorMaster as doc on con.DrCode=doc.id where con.DrCode='" + HttpContext.Current.Session["DrCode"] + "' ");
            IList events = new List<Event>();
            for (int i = 0; i < dt1.Rows.Count; i++)
            {
                DataRow dRow4 = dt1.Rows[i];
                events.Add(new Event
                {
                   start = Convert.ToDateTime(dRow4["Date"].ToString()).ToString("yyyy-MM-dd") + "T" + dRow4["Time"].ToString(),
                    end = Convert.ToDateTime(dRow4["Date"].ToString()).ToString("yyyy-MM-dd") + "T" + dRow4["Time"].ToString(),
                    title = dRow4["pfname"].ToString(),
                    Appointment = dRow4["Appointment"].ToString(),
                    Time = dRow4["Time"].ToString()

                });
            }
            return events;
    }
}
public class Event
{
    public string start { get; set; }
    public string end { get; set; }
    public string title { get; set; }
    public string Appointment { get; set; }
    public string Time { get; set; }
}

【问题讨论】:

  • fullcalendar.io/docs/eventRender 给出了一个基本示例 - 它需要您可以搜索和下载的“qtip”库,或者您可以使用任何其他方式在 JavaScript 中显示弹出框,没关系.

标签: javascript c# asp.net ajax fullcalendar


【解决方案1】:

您需要覆盖完整日历的 eventRender 属性。

 $('#calendar').fullCalendar({
    defaultView: 'month',
    defaultDate: '2018-10-12',

    eventRender: function(eventObj, $el) {
      $el.popover({
        title: eventObj.title,
        content: eventObj.description,
        trigger: 'hover',
        placement: 'top',
        container: 'body'
      });
    },

    events: [
      {
        title: 'All Day Event',
        description: 'description for All Day Event',
        start: '2018-10-01'
      },
      {
        title: 'Long Event',
        description: 'description for Long Event',
        start: '2018-10-07',
        end: '2018-10-10'
      },
      {
        id: 999,
        title: 'Repeating Event',
        description: 'description for Repeating Event',
        start: '2018-10-09T16:00:00'
      },
      {
        id: 999,
        title: 'Repeating Event',
        description: 'description for Repeating Event',
        start: '2018-10-16T16:00:00'
      },
      {
        title: 'Conference',
        description: 'description for Conference',
        start: '2018-10-11',
        end: '2018-10-13'
      },
      {
        title: 'Meeting',
        description: 'description for Meeting',
        start: '2018-10-12T10:30:00',
        end: '2018-10-12T12:30:00'
      },
      {
        title: 'Lunch',
        description: 'description for Lunch',
        start: '2018-10-12T12:00:00'
      },
      {
        title: 'Meeting',
        description: 'description for Meeting',
        start: '2018-10-12T14:30:00'
      },
      {
        title: 'Birthday Party',
        description: 'description for Birthday Party',
        start: '2018-10-13T07:00:00'
      },
      {
        title: 'Click for Google',
        description: 'description for Click for Google',
        url: 'http://google.com/',
        start: '2018-10-28'
      }
    ]
  });

工作示例是here

更多参考请参阅完整日历docs

【讨论】:

    猜你喜欢
    • 2019-12-03
    • 1970-01-01
    • 1970-01-01
    • 2019-12-26
    • 2015-01-16
    • 1970-01-01
    • 2022-10-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多