fullcalendar从数据库中检索 [英] fullcalendar retrieving from database

查看:317
本文介绍了fullcalendar从数据库中检索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用完整的日历网上呈现的时间表。理想情况下,我想有很多的功能,与此有关。最初,我想它含有对特定用户的事件表连接到我的SQL数据库,检索数据。我使用SQL服务器紧凑和C#和剃刀语法。什么是去这样做的最佳方式?

I am trying to use full calendar to render a timetable online. Ideally, I'd like to have a lot of functionality with this. Initially, I would like to connect it to my SQL database, retrieve data from a table containing events for a particular user. I am using SQL compact server and C# and the Razor syntax. What is the best way to go about doing this?

我的选择演示从网站的工作,到目前为止,我的code是这样的:

I am working with the selectable demo from the website and so far my code is this :

<html>
<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar.css' />
<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar.print.css' media='print' />
<script type='text/javascript' src='../jquery/jquery-1.7.1.min.js'></script>
<script type='text/javascript' src='../jquery/jquery-ui-1.8.17.custom.min.js'></script>
<script type='text/javascript' src='../fullcalendar/fullcalendar.min.js'></script>
<script type='text/javascript'>

    $(document).ready(function() {

        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        var calendar = $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            selectable: true,
            selectHelper: true,
            select: function(start, end, allDay) {
                var title = prompt('Event Title:');
                if (title) {
                    calendar.fullCalendar('renderEvent',
                        {
                            title: title,
                            start: start,
                            end: end,
                            allDay: allDay
                        },
                        true // make the event "stick"
                    );
                }
                calendar.fullCalendar('unselect');
            },
            editable: true,
            events: [
                {
                    title: 'All Day Event',
                    start: new Date(y, m, 1)
                },
                {
                    title: 'Long Event',
                    start: new Date(y, m, d-5),
                    end: new Date(y, m, d-2)
                },
                {
                    id: 999,
                    title: 'Repeating Event',
                    start: new Date(y, m, d-3, 16, 0),
                    allDay: false
                },
                {
                    id: 999,
                    title: 'Repeating Event',
                    start: new Date(y, m, d+4, 16, 0),
                    allDay: false
                },
                {
                    title: 'Meeting',
                    start: new Date(y, m, d, 10, 30),
                    allDay: false
                },
                {
                    title: 'Lunch',
                    start: new Date(y, m, d, 12, 0),
                    end: new Date(y, m, d, 14, 0),
                    allDay: false
                },
                {
                    title: 'Birthday Party',
                    start: new Date(y, m, d+1, 19, 0),
                    end: new Date(y, m, d+1, 22, 30),
                    allDay: false
                },
                {
                    title: 'Click for Google',
                    start: new Date(y, m, 28),
                    end: new Date(y, m, 29),
                    url: 'http://google.com/'
                }
            ]
        });

    });

</script>
<style type='text/css'>

    body {
        text-align: center;
        font-size: 14px;
        font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
        }

    #calendar {
        width: 800px;
        margin: 0 auto;
        }

</style>
</head>
<body>
<div id='calendar'></div>
</body>
</html>

这是保存在一个.html文件。我猜最好的办法是将其转换为一个.cshtml的形式和使用C#连接到一个类似这样的数据库:

This is saved in a .html file. I'm guessing the best way would be to convert this to a .cshtml form and use C# to connect to a a database similar to this :

@{
    var db = Database.Open("myDB");
    var Name = Request["Title"];
    var Description = Request["Start"];
    var Price = Request["End"];
    var allDay = Request["myDB"];
}

什么是填充使用这个我在JavaScript事件的最佳方式?

What is the best way of populating my events in the JavaScript using this?

推荐答案

我会看一些如JSON饲料的其他例子。在这里,您可以使用PHP,或在我的情况下,.NET连接到后端数据库,这将提供一个'回复'作为一个JSON的饲料。 FullCallendar有所有code国米preT这饲料并显示它们。

I would look at some of the other examples such as json feed. Here you can use a php, or as in my case a .net connection to a backend database which will provide a 'reply' as a json feed. FullCallendar has all the code to interpret this feed and display them.

这篇关于fullcalendar从数据库中检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆