javascript - Is it possible to set colors per single event within events: [] in FullCalendar? -


I am using FullCalendar

I am creating an event: [] List using PHP:

  & lt ;? Php $ dbh = new PDO ('mysql: host = local host; dbname = calendar', 'user', 'pass'); $ Stmt = $ dbh- & gt; Prepare ("Choose from Vacations"); $ Stmt- & gt; Executed (); $ Return_array = array (); $ Event_array; While ($ line = $ stmt-> fetch (PDO :: FETCH_ASSOC)) {$ event_array = array (); $ Event_array ['id'] = $ line ['id']; $ Event_arre ['title'] = $ line ['id'] "-" $ line ['first name'] "" $ line ['alias']; $ Event_array ['Start'] = $ line ['Start']; $ Event_arre ['end'] = $ line ['and']; $ Event_array ['allDay'] = true; // What do I do ($ line ['department'] == 'UK') {$ event_array ['color'] = '# 000000'; }; If ($ line ['department'] == 'US') {$ event_array ['color'] = '# 000000'; }; Else {$ event_array ['color'] = '# 000000'; }; Array_push ($ return_array, $ event_array); } Echo json_encode ($ return_array); ? & Gt;  

I want to know whether it is possible to paint each individual event within the array. I see that it is possible to set the color, but they are set to the entire eventSources: [] instead of one color that can change per event in the same eventSource .

Is it possible to do this?

I'm assuming that your JS is correct, displaying your Jason array, your JS code Can not tell without it.

Name has been there named className , which will specify the square in each event.

In your example, you should be able to do something like this:

  while receiving ($ line = $ stmt-> (PDFO: FETCH_ASSOC)) { $ Event_array = array (); $ Event_array ['id'] = $ line ['id']; $ Event_arre ['title'] = $ line ['id'] "-" $ line ['first name'] "" $ line ['alias']; $ Event_array ['Start'] = $ line ['Start']; $ Event_arre ['end'] = $ line ['and']; $ Event_array ['allDay'] = true; // Apply a different class based on the department if ($ line ['department'] == 'uk') {$ event_array ['className'] = 'uk_event'; } And if ($ line ['department'] == 'US') {$ event_array ['className'] = 'us_event'; } And {$ event_array ['className'] = 'normal_event'; }; Array_push ($ return_array, $ event_array); }  

Then on the page where you display your calendar, for example: you

  .uk_event {background-color blue; } .us_event {background color: red; } .general_event {background-color: black; }  

UK events must be blue to color, the U.S. Events colorful red etc ...

I created calendars with full calendar, I should be more specific and apply style changes in the child's div:

 . Uk_event div {background-color: blue; }  

Make sure it is now necessary, or why I did it, then back. One version may be the difference, I am not sure, try both and see if there is any work.

This is a general idea how to do it.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -