Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
public IActionResult Index()
{
ViewBag.DataSource = ganttData();
return View();

}

public static List<GanttDataSource> ganttData()
{
List<GanttDataSource> GanttDataSourceCollection = new List<GanttDataSource>();

GanttDataSource Record1 = new GanttDataSource()
{
TaskId = 1,
TaskName = "Project initiation",
StartDate = new DateTime(2019, 04, 02),
EndDate = new DateTime(2019, 04, 21),
};
GanttDataSource Record2 = new GanttDataSource()
{
TaskId = 2,
TaskName = "Identify site location",
StartDate = new DateTime(2019, 04, 02),
BaselineStartDate = new DateTime(2019, 04, 02),
BaselineEndDate = new DateTime(2019, 04, 02),
Duration = 0,
Progress = 70,
ParentId = 1
};
GanttDataSource Record3 = new GanttDataSource()
{
TaskId = 3,
TaskName = "Perform soil test",
StartDate = new DateTime(2019, 04, 02),
BaselineStartDate = new DateTime(2019, 04, 04),
BaselineEndDate = new DateTime(2019, 04, 09),
Duration = 8,
Progress = 50
ParentId = 1
};
GanttDataSource Record4 = new GanttDataSource()
{
TaskId = 4,
TaskName = "Soil test approval",
StartDate = new DateTime(2019, 04, 02),
BaselineStartDate = new DateTime(2019, 04, 08),
BaselineEndDate = new DateTime(2019, 04, 12),
Duration = 4,
Progress = 50,
ParentId = 1
};

GanttDataSource Record5 = new GanttDataSource()
{
TaskId = 5,
TaskName = "Project estimation",
StartDate = new DateTime(2019, 04, 02),
EndDate = new DateTime(2019, 04, 21),
};
GanttDataSource Record6 = new GanttDataSource()
{
TaskId = 6,
TaskName = "Develop floor plan for estimation",
StartDate = new DateTime(2019, 04, 04),
BaselineStartDate = new DateTime(2019, 04, 08),
BaselineEndDate = new DateTime(2019, 04, 12),
Duration = 4,
Progress = 70,
ParentId = 5
};
GanttDataSource Record7 = new GanttDataSource()
{
TaskId = 7,
TaskName = "List materials",
StartDate = new DateTime(2019, 04, 04),
BaselineStartDate = new DateTime(2019, 04, 02),
BaselineEndDate = new DateTime(2019, 04, 02),
Duration = 0,
Progress = 50,
ParentId = 5
};

GanttDataSourceCollection.Add(Record1);
GanttDataSourceCollection.Add(Record2);
GanttDataSourceCollection.Add(Record3);
GanttDataSourceCollection.Add(Record4);
GanttDataSourceCollection.Add(Record5);
GanttDataSourceCollection.Add(Record6);
GanttDataSourceCollection.Add(Record7);

return GanttDataSourceCollection;
}

public class GanttDataSource
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int? Duration { get; set; }
public DateTime? BaselineStartDate { get; set; }
public DateTime? BaselineEndDate { get; set; }
public int Progress { get; set; }
public int? ParentId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

@Html.EJS().Gantt("Gantt").DataSource((IEnumerable<object>)ViewBag.DataSource).RenderBaseline(
true).Height("450px").TaskFields(ts => ts.Id("TaskId").Name("TaskName").StartDate("StartDate").BaselineStartDate(
"BaselineStartDate").Duration("Duration").BaselineEndDate("BaselineEndDate").Progress("Progress").ParentId("ParentId")).BeforeTooltipRender("BeforeTooltipRender").Render()

<script type="text/javascript">
function BeforeTooltipRender(args) {
if (args.args.target.classList.contains("e-baseline-bar")) {
args.cancel = true;
}
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<ejs-gantt id='Gantt' dataSource="ViewBag.DataSource" height="450px" renderBaseline="true" baselineColor="red" beforeTooltipRender="beforeTooltipRender">
<e-gantt-taskfields id="TaskId" baselineStartDate="BaselineStartDate" baselineEndDate="BaselineEndDate" name="TaskName" startDate="StartDate" endDate="EndDate" duration="Duration" progress="Progress" child="SubTasks">
</e-gantt-taskfields>
</ejs-gantt>

<script type="text/javascript">
function beforeTooltipRender(args)
{
if (args.args.target.classList.contains("e-baseline-bar"))
{
args.cancel = true;
}
}
</script>
47 changes: 45 additions & 2 deletions ej2-asp-core-mvc/gantt/taskbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,55 @@ A baseline tooltip can be customized using the [`TooltipSettings.Baseline`](http
{% endtabs %}
{% endif %}



The following screenshot shows the template for baseline in Gantt.

![Alt text](images/baselineTemplate.png)

#### Preventing Baseline Tooltip Display

In the Gantt chart, baseline tooltips are automatically displayed when hovering over baseline bars. In certain scenarios, it may be necessary to conditionally control the visibility of these tooltips.
This can be achieved using the [`beforeTooltipRender`](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.gantt.gantt.html#Syncfusion_EJ2_Gantt_Gantt_BeforeTooltipRender) event, which allows customization of tooltip behavior before it is rendered.

##### Using the beforeTooltipRender Event

The `beforeTooltipRender` event is triggered when hovering over chart elements, including baseline bars. By checking the class of the target element, tooltip rendering can be canceled based on specific conditions.

```javascript
function beforeTooltipRender(args)
{
if (args.args.target.classList.contains("e-baseline-bar"))
{
args.cancel = true;
}
}

```

In this example, tooltip rendering is prevented for baseline bars by setting `args.cancel` to `true`.

{% if page.publishingplatform == "aspnet-core" %}

{% tabs %}
{% highlight cshtml tabtitle="CSHTML" %}
{% include code-snippet/gantt/tooltip/baselineTootipHide/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="baselineTootipHide.cs" %}
{% include code-snippet/gantt/tooltip/baselineTootipHide/baselineTootipHide.cs %}
{% endhighlight %}
{% endtabs %}

{% elsif page.publishingplatform == "aspnet-mvc" %}

{% tabs %}
{% highlight razor tabtitle="CSHTML" %}
{% include code-snippet/gantt/tooltip/baselineTootipHide/razor %}
{% endhighlight %}
{% highlight c# tabtitle="baselineTootipHide.cs" %}
{% include code-snippet/gantt/tooltip/baselineTootipHide/baselineTootipHide.cs %}
{% endhighlight %}
{% endtabs %}
{% endif %}

### Connector line tooltip

The default connector line tooltip in the Gantt control can be customized using the [`TooltipSettings.ConnectorLine`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Gantt.GanttTooltipSettings.html#Syncfusion_EJ2_Gantt_GanttTooltipSettings_ConnectorLine) property. You can map the value to this property as template script element ID or template string format. The following code example shows how to use the [`TooltipSettings.ConnectorLine`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Gantt.GanttTooltipSettings.html#Syncfusion_EJ2_Gantt_GanttTooltipSettings_ConnectorLine) property.
Expand Down