Gantt Task background color from database

Hi,

I implemented the gantt control with datasource using entity framework, and each project have a color. Is it possible to customize the tasks in gantt to use the project color?


thank you

4 Replies

LG Logeswari Gopalakrishnan Syncfusion Team April 30, 2020 04:50 PM UTC

Hi Helder, 
Yes, it is possible to customize the tasks in Gantt using queryTaskbarInfo event. For this we need to define custom fields in data source and using this field value we can customize the taskbar. Please find the below code example. 
<ejs-gantt id='RemoteData' queryTaskbarInfo="window.queryTaskbarInfo"> 
    //... 
    <e-gantt-columns> 
    //... 
        <e-gantt-column field="TaskColor"  visible="false"></e-gantt-column> 
    </e-gantt-columns> 
</ejs-gantt> 
<script type="text/javascript"> 
    window.queryTaskbarInfo = function (args) { 
        if (args.data.TaskColor) 
            args.taskbarBgColor = args.data.TaskColor;      
    } 
</script> 
Please find the below sample link. 
It is also possible to customize the task using taskbar template support. 

Regards, 
Logeswari G 



HM Helder Meneses April 30, 2020 05:16 PM UTC

Hi,

it's almost there :). The Color comes from the project, the task doesnt have the color column, only project. Is it possible to get the project color column, or do i need to create a column in the task database table and clone the project color?

thank you...


HM Helder Meneses April 30, 2020 05:53 PM UTC

I figured out a way to read the project color. It worked flawlessly...

thank you...


PP Pooja Priya Krishna Moorthy Syncfusion Team May 1, 2020 09:05 AM UTC

Hi Helder, 

Thanks for your update. 
We are happy to hear that your issue has been resolved. 
Please get back to us if you require further assistance on this. 

Regards, 
Pooja K 


Loader.
Up arrow icon