Apply colour to data from a database


#1

Hi,

I’m struggling to figure out how to to set different entries to different colours from data coming from a table. with the sample code pasted into my code, the json data shows the various colours I want to do the same with the data from the table… It pulls from the table via php (the stock examples modified…)

in the events table, I have a field rec_type that gets pulled into the calendar data which i will set the colour to the current entry depending on that value (USER, LEAD, CONTRACT)

i’m just not sure where to start or where to apply the color to the data

any insight appreciated


coloring the event using server side data
#2

Hi, Sticcino,
There are 3 ways in the sсheduler to assign different colors to each event in accordance with a certain parameter in the data:

  1. The first way is to set the background color and / or text color using the color and textColor properties, respectively, in the data object:
    https://docs.dhtmlx.com/scheduler/custom_events_color.html#specifyingcolorsinpropertiesoftheeventobject
  2. The next way is to specify the related CSS classes of the events. In order to do this, define a new type in the event data object and assign a value to it. Modify the CSS classes associated with these event types. Using the event_class template add your own class with the given styles:
    https: // docs.dhtmlx.com/scheduler/custom_events_color.html#attachingadditionalcssclassestoanevent
  3. The third method allows you to dynamically create new classes for your events. You create a new data collection using the serverList method. When onParse event fires you can generate CSS styles from the serverList. After that you can assign related classes from the event_class template:
    https://docs.dhtmlx.com/scheduler/custom_events_color.html#loadingcolorswithdata
    I’ve made a quick demos that show how it can be implemented in various ways:

#3

Hi,

thanks for the information, appreciated. I’ll study it and implement