2017-08-07 151 views
0

我試圖改變日曆的顏色, 我有這樣 calender 日曆我想做的事就是這樣calender 我已經能夠添加顏色事件文本,但該事件的背景。 這是我的代碼。如何更改Fullcalendar日期字段的背景顏色?

控制器:

public function actionEvent(){ 

    $events= \app\models\Events::find()->all(); 
    $tasks=[]; 
    foreach ($events as $eve){ 
    $event = new \yii2fullcalendar\models\Event(); 
    $event->id = $eve->id; 
    $event->title =$eve->event_title; 
    $event->start =$eve->start_date; 
    $event->end =$eve->end_date; 
    $event->backgroundColor = 'green'; 
    $event->description=$eve->event_description ." <hr><b> Location: </b>".$eve->location." " . " <br/><b> Organizer: </b>".$eve->organizer." " ; 
    $tasks[] = $event; 
    } 
    return $this->render('events',['events'=>$tasks,'test'=>$tasks]); 
    // return $this->render('events'); 
} 

查看:

$thame=<<<EOF 
      function(calEvent, jsEvent, view) { 
      $(this).css('background', '#DBBEBE'); 


      } 
EOF; 
    ?> 
    <?= \yii2fullcalendar\yii2fullcalendar::widget(array(

    'events'=> $events, 
    'clientOptions' => [ 
     // 'weekends' => true, 
     // 'language' => 'fa', 
     //'eventLimit' => TRUE, 
     //'droppable' => true, 
     // 'editable' => true, 
     'theme'=>new JsExpression($thame), 
     // 'fixedWeekCount' => true, 
     'eventClick' => new JsExpression($ClickMe), 
     'defaultDate' => date('Y-m-d'), 

    ],  
));?> 

誰能幫助?

回答

0

我認爲這將有利於你 -

按照他們的文檔,你可以使用eventBackgroundColor

{ 
    events: [ 
     { 
      title: 'Event1', 
      start: '2011-04-04' 
     }, 
     { 
      title: 'Event2', 
      start: '2011-05-05' 
     } 
     // etc... 
    ], 
    color: 'yellow', // an option! 
    textColor: 'black' // an option! 
} 

如果你想周圍的其他工作,在您的自定義樣式添加下面的代碼 -

.fc-event{ 
    background-color: yellow !important; /* only use !important if calendar's default style is overwriting your style */ 
} 
+0

究竟是如何做到這一點在Yii2工具?我是新的 – snew

+0

@snew是否在插件中使用了任何'樣式表'。?如果它存在,那麼只需在樣式表的答案中添加樣式。 – weBBer

+0

它只改變事件文本的背景。不是全天塊。 – snew