Jquery完整日历问题 - 关于事件组和事件的颜色多个事件源 [英] Jquery Full Calendar Questions - Color on group of events & multiple event sources

查看:105
本文介绍了Jquery完整日历问题 - 关于事件组和事件的颜色多个事件源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



多个来源将如何显示?

  jQuery $ .ajax选项

您也可以在同一个对象中指定任何jQuery $ .ajax选项!这允许您轻松地将其他参数传递到您的供稿脚本,以及侦听ajax回调:
$ b $('#calendar')。fullCalendar({

eventSources: [

//您的活动来源
{
url:'/myfeed.php',
类型:'POST',
data:{
custom_param1:'something',
custom_param2:'somethingelse'
}
错误:function(){
alert('提取事件时发生错误!') ;
},
颜色:'yellow',//非ajax选项
textColor:'black'//非ajax选项
}

//任何其他来源...

]

});

来自: http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/



您只需输入逗号然后复制基本上第一个?

我的第二个问题是。我将有一个事件源(因为它们都来自同一个源),但我会在那里有一些事件组,并且每个组都需要不同的颜色。



所以我可以有这个

 项目1  - 组1(红色)
项目2 - 组1(红色)
第3组 - 第2组(绿色)
第4组 - 第3组(黑色)

现在这些颜色是由用户设置的,所以我永远不会知道一个颜色组是什么颜色。一个用户可能会设置为红色,可能会将其设置为蓝色。



所以我想我需要为每个事件发送颜色。所以Item 1会有一个与它相关的颜色,而Item 2会有一个颜色相关的等等。



这个怎么做?我想我一旦得到事件回来就需要做点什么。我只是不确定是什么。



谢谢

解决方案

多个来源,你是对的,只需添加更多的eventSources数组:

  $('#calendar')。fullCalendar {

eventSources:[

//您的活动来源
{
url:'/myfeed.php',
type:' POST',
data:{
custom_param1:'something',
custom_param2:'somethingelse'
}
error:function(){
alert( ');
},
color:'yellow',//非ajax选项
textColor:'black'//非ajax选项
},

//第二个事件源
{
url:'/myfeed.php',
类型:'POST',
数据:{
custom_param3:'somethingelseelse',
custom_param4:'somethingelseelseelse'
}
错误:function(){
alert('提取事件时发生错误!
},
颜色:'red',//非ajax选项
textColor:'white'//非ajax选项
}

//任何其他来源...

]

});至于多个组的不同颜色,fullCalendar每个事件源只允许一种颜色。因此,您必须为每个组添加一个源到eventSource。至于让用户定制他们的颜色,使用上面的例子,你可以有这样的事情:

  $(' #calendar')。fullCalendar({

eventSources:[

//您的活动来源
{
url:'/myfeed.php',
type:'POST',
data:{
custom_param1:'something',
custom_param2:'somethingelse'
}
error:function() {
alert('提取事件时发生错误!');
},
color:settings.customBackgroundColors(userId,groupX),//非ajax选项
textColor:settings.customTextColors(userId,groupX)//非ajax选项
},

//第二个事件源
{
url:' /myfeed.php',
类型:'POST',
数据:{
custom_param3:'somethingelseelse',
custom_param4:'somethingelseelseelse'
}
error:function(){
alert('提取事件时发生错误!
},
color:settings.customBackgroundColors(userId,groupY),//一个非ajax选项
textColor:settings.customTextColors(userId,groupY)//一个非ajax选项
}

//任何其他来源...

]

});



编辑



如果您希望像个别颜色这样的来自json feed的每个事件的单独属性做这样的事情。

  public int id {get;组; } 
public string title {get;组; }
public bool allDay {get;组; }
public string start {get;组; }
public string end {get;组; }
public string color {get;组; }
public string textColor {get;组; }

用你想要的颜色填充字符串,然后将其发送回json结果,并且每个任务应使用您在颜色属性中设置的任何内容。


I am looking at jquery full calendar 1.5 and have a couple questions.

How would multiple source look like?

jQuery $.ajax options

You can also specify any of the jQuery $.ajax options within the same object! This allows you to easily pass additional parameters to your feed script, as well as listen to ajax callbacks:

    $('#calendar').fullCalendar({

        eventSources: [

            // your event source
            {
                url: '/myfeed.php',
                type: 'POST',
                data: {
                    custom_param1: 'something',
                    custom_param2: 'somethingelse'
                }
                error: function() {
                    alert('there was an error while fetching events!');
                },
                color: 'yellow',   // a non-ajax option
                textColor: 'black' // a non-ajax option
            }

            // any other sources...

        ]

    });

from: http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/

Would you just put a comma and then copy basically the first one?

My second question is. I am going to have one event source(since they all come from the same source) but I will have groups of events in there and each group needs a different color.

So I could have this

Item 1 - group 1 (color red)
Item 2 - group 1 (color red)
Item 3 - group 2  (color green)
Item 4 - group 3 (color black)

Now these colors are set by the user so I will never know what color group one will be. One user might set it red one might set it blue.

So I thinking that I need to send the color with each event. So Item 1 would have a color associated with it and Item 2 would have a color associated and etc.

How would do this? I am thinking I need to do something once I get the events back. I am just not sure what.

Thanks

解决方案

To handle multiple sources, you're right, just add more to the eventSources array:

$('#calendar').fullCalendar({

    eventSources: [

        // your event source
        {
            url: '/myfeed.php',
            type: 'POST',
            data: {
                custom_param1: 'something',
                custom_param2: 'somethingelse'
            }
            error: function() {
                alert('there was an error while fetching events!');
            },
            color: 'yellow',   // a non-ajax option
            textColor: 'black' // a non-ajax option
        },

        // your second event source
        {
            url: '/myfeed.php',
            type: 'POST',
            data: {
                custom_param3: 'somethingelseelse',
                custom_param4: 'somethingelseelseelse'
            }
            error: function() {
                alert('there was an error while fetching events!');
            },
            color: 'red',   // a non-ajax option
            textColor: 'white' // a non-ajax option
        }

        // any other sources...

    ]

});

As far as different colors for multiple groups, fullCalendar only allows one color per event source. So you'll have to add one source to eventSource for each group you have. And as far as letting the user customize their colors, using the example above, you can have something like this:

$('#calendar').fullCalendar({

    eventSources: [

        // your event source
        {
            url: '/myfeed.php',
            type: 'POST',
            data: {
                custom_param1: 'something',
                custom_param2: 'somethingelse'
            }
            error: function() {
                alert('there was an error while fetching events!');
            },
            color: settings.customBackgroundColors(userId, groupX),   // a non-ajax option
            textColor: settings.customTextColors(userId, groupX) // a non-ajax option
        },

        // your second event source
        {
            url: '/myfeed.php',
            type: 'POST',
            data: {
                custom_param3: 'somethingelseelse',
                custom_param4: 'somethingelseelseelse'
            }
            error: function() {
                alert('there was an error while fetching events!');
            },
            color: settings.customBackgroundColors(userId, groupY),   // a non-ajax option
            textColor: settings.customTextColors(userId, groupY) // a non-ajax option
        }

        // any other sources...

    ]

});


Edit

If you want individual properties for each of your events from a json feed like a individual color do something like this.

public int id { get; set; }
public string title { get; set; }
public bool allDay { get; set; }
public string start { get; set; }
public string end { get; set; }
public string color { get; set; }
public string textColor { get; set; }

fill in the string with the color you want make a collection of what I have for each event and then send it back a a json result and each task should use whatever you set in the color property.

这篇关于Jquery完整日历问题 - 关于事件组和事件的颜色多个事件源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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