【问题标题】:Changing background-color of event in jquery full calendar在jQuery完整日历中更改事件的背景颜色
【发布时间】:2013-07-18 09:14:56
【问题描述】:

我有一个 Web 应用程序 (asp.net mvc4),我在其中使用了 Jquery Full Calendar site

  <script>

        $(document).ready(function () {
            var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();
            var tab = [];
            var d1 = [];
            var m1 = [];
            var y1 = [];
            var d2 = [];
            var m2 = [];
            var y2 = [];
            var colors = [];
            
             @for(int i =0; i< @Model.Get_List_Tache().Count;i++){
                 @: d1.push(@Model.Get_List_Tache()[i].Begin_date.Day);
                 @: m1.push(@Model.Get_List_Tache()[i].Begin_date.Month);
                 @: y1.push(@Model.Get_List_Tache()[i].Begin_date.Year);
                 @: d2.push(@Model.Get_List_Tache()[i].End_date.Day);
                 @: m2.push(@Model.Get_List_Tache()[i].End_date.Month);
                 @: y2.push(@Model.Get_List_Tache()[i].End_date.Year);
                         }
            d1.reverse();
            m1.reverse();
            y1.reverse();
            d2.reverse();
            m2.reverse();
            y2.reverse();
            @for(int i =0; i< @Model.Get_List_Tache().Count;i++){
            @:var e = { title: "Tache: @Model.Get_List_Tache()[i].Tache_description", start: new Date(y1.pop(), m1.pop() - 1, d1.pop(), 08, 00), end: new Date(y2.pop(), m2.pop() - 1, d2.pop(), 18, 00), allDay: true};
            @: tab.push(e);
        }                      
      $('#calendar').fullCalendar({
                theme: true,
                header: {left: 'prev,next today',center: 'title',right: 'month,agendaWeek,agendaDay'},
                editable: true,
                events: tab
      });
        });
         @for (int i = 0; i < @Model.GetColors().Count; i++)
         {
           
         }

</script>

我有一个模型GetColors()中的颜色列表

public List<string> GetColors() {
            Sa_group sadmin = new Sa_group();
            Equipe _equipe = new Equipe();
            List<string> _out = new List<string>();
            List<Tache> liste_initiale = _equipe.Get_List_tache();
            foreach (Tache t in liste_initiale) {
                if (t.Id_tache_status == 1) { _out.Add("red"); }
                if (t.Id_tache_status == 2) { _out.Add("green"); }
                if (t.Id_tache_status == 3) { _out.Add("black"); }
                                                }
            return _out;
        }

所以,我需要将events 中每个元素的background-color 更改为GetColors() 的值。

我怎样才能完成这项任务?有什么建议吗?

【问题讨论】:

    标签: c# jquery .net css fullcalendar


    【解决方案1】:

    嗨,Lamloumi 您可以在事件对象属性中看到className,您可以在每个事件中设置它允许您为每个事件定义一个 CSS 类,然后在 CSS 中为每种类型的事件背景颜色定义每种颜色.如果颜色是动态的,我的意思是如果它们不完全相同,您可以使用 Jquery 或 javascript 来“动态”更改 css 类。

    如果您需要进一步解释,请告诉我。

    长寿和繁荣。

    【讨论】:

      猜你喜欢
      • 2015-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-05
      • 2011-01-27
      • 2019-09-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多