Problem with fetching data form SQL Server DB
hi there, for my project I am looking at the potential of gantt. I have an initial problem and cannot proceed. I am not displaying data taken from a SQL Server table. I enclose some documentation.
for the class the db and the data I have copied your basic documentation examples for now.
I also made a table to check whether the data are in fact displayed. In the grid the data is there, in the gantt I see nothing. when i render the page the rorr is No records to display seems like that datasource is empty.
THX for all
Class
public int Id { get; set; }
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public string? Duration { get; set; }
public int? Progress { get; set; }
public int? ParentId { get; set; } = 0;
public DateTime? DueDate { get; set; }
public double? TimeLog { get; set; }
public double? Work { get; set; }
public string? Assignee { get; set; }
public string? Manager { get; set; }
public string? Predecessor { get; set; }
public double? StoryPoints { get; set; }
public string? Status { get; set; }
public string? Priority { get; set; }
public string? Component { get; set; }
DB Select
Id TaskId TaskName StartDate EndDate Duration Progress ParentId DueDate TimeLog Work Assignee Manager Predecessor StoryPoints Status Priority Component
1000000 1 Project initiation 2021-04-21 00:00:00.0000000 2022-05-04 00:00:00.0000000 30 10 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
1000004 2 Identify Site location 2022-04-05 00:00:00.0000000 2022-04-09 00:00:00.0000000 4 50 1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
Entire code of the page
@page "/gantt2"
@rendermode RenderMode.InteractiveServer
@inject ITaskDataService TaskDataService
<SfGrid DataSource="@TaskCollection" AllowPaging="true">
<GridColumns>
<GridColumn Field=@nameof(TaskData.Id) HeaderText="ID" TextAlign="TextAlign.Left" Width="120"></GridColumn>
<GridColumn Field=@nameof(TaskData.TaskId) HeaderText="TSK ID" TextAlign="TextAlign.Left" Width="120"></GridColumn>
<GridColumn Field=@nameof(TaskData.TaskName) HeaderText="Desc" TextAlign="TextAlign.Left" Width="120"></GridColumn>
<GridColumn Field=@nameof(TaskData.StartDate) HeaderText="Start" TextAlign="TextAlign.Left" Width="120"></GridColumn>
<GridColumn Field=@nameof(TaskData.EndDate) HeaderText="End" TextAlign="TextAlign.Left" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
<br />
<br />
<br />
<SfGantt DataSource="@TaskCollection" Height="450px" Width="700px">
<GanttTaskFields
Id="TaskId"
Name="TaskName"
StartDate="StartDate"
EndDate="EndDate"
Duration="Duration"
Progress="Progress"
ParentID="ParentId">
</GanttTaskFields>
<GanttColumns>
<GanttColumn Field="TaskId" HeaderText="Task ID" TextAlign="TextAlign.Right" Width="100"></GanttColumn>
<GanttColumn Field="TaskName" HeaderText="Task Name" Width="250"></GanttColumn>
<GanttColumn Field="StartDate" HeaderText="Start Date" Width="250"></GanttColumn>
<GanttColumn Field="Duration" HeaderText="Duration" Width="250"></GanttColumn>
<GanttColumn Field="Progress" HeaderText="Progress" Format="@NumberFormat" Width="250"></GanttColumn>
</GanttColumns>
</SfGantt>
@code {
private List<TaskData> TaskCollection { get; set; } = new List<TaskData>();
public List<TaskData> tasksDataSource = new List<TaskData>();
private string NumberFormat = "C";
//protected override void OnInitialized()
protected override async Task OnInitializedAsync()
{
this.TaskCollection = await TaskDataService.SGetTaskDatas();
tasksDataSource = await TaskDataService.SGetTaskDatas();
}
}
Service
Interface
Task> SGetTaskDatas();
class that implements interface (i do so every time)
public async Task> SGetTaskDatas()
{
var taskdata = await _context.TaskDatas.ToListAsync();
return taskdata;
}
Hi
Francesco,
Greetings
from Syncfusion Support,
We have reviewed your query, and we are also using SQL Server to retrieve data through the interface. However, we are unable to replicate the issue on our end. We have attached a video reference for you to refer to.
Document
link: https://blazor.syncfusion.com/documentation/common/data-binding/bind-entity-framework
Video reference : https://www.syncfusion.com/downloads/support/directtrac/general/ze/SqlServer-989596115.zip
Before proceed this, we request you to share more information to find the cause of the issue. Kindly share the information below.
- Have you faced the issue on any Specific scenario or enabling specific properties .
- Complete Gantt code with project example.
- Specific scenario you have faced the issue(Video demo).
- Exception occurs on console window(if any) or Bind ActionFailure Event and share the error details from its args.
- Information about package details.
- If possible, replicate the issue in a shared sample and revert back to us.
Once we receive this information, we will be better equipped to identify the root cause of the issue and provide you with the necessary assistance.
Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/GanttSqlServer-812694205.zip
Regards,
Ajithkumar G
Cheers, i'll try to modify my code, but the question is that i can't render project task in gantt with my code .
Hi Francesco,
Query 1: the question is that i can't render project task in gantt with my code
Before proceed this, we request you to share more information to find the cause of the issue. Kindly share the information below.
- Video Demo/Screenshot of the issue you have faced.
- Could you confirm whether the task collection is updating correctly? If updated, kindly share a screenshot for verification.
- If possible, replicate the issue in a previously shared sample and revert back to us.
- Exception occurs on console window(if any) or Bind ActionFailure Event and share the error details from its args.
Once we receive this information, we will be better equipped to identify the root cause of the issue and provide you with the necessary assistance.
Regards,
Ajithkumar G
Hi there , i did some tests
New Service interface
Task<List<ProjectTask>> SGetProjectTasks();
// Syncfusion Test
List<ProjectTask> GetGanttData();
New service
public async Task<List<ProjectTask>> SGetProjectTasks()
{
var projecttasks = await _context.ProjectTasks.ToListAsync();
return projecttasks;
}
// Syncfusion test
public List<ProjectTask> GetGanttData()
{
return _context.ProjectTasks.ToList();
}
New Code
@code {
private List<ProjectTask> TaskCollectionList { get; set; }
private List<ProjectTask> TaskCollectionList2 { get; set; }
protected override async Task OnInitializedAsync()
{
this.TaskCollectionList2 = await ProjectTaskService.SGetProjectTasks();
}
protected override void OnInitialized()
{
this.TaskCollectionList = ProjectTaskService.GetGanttData3();
}
}
Now with new GetGanttData() and with protected override void OnInitialized()
i can render my data. Seems that my OnInitializedAsync() don't works or something in returned datasource
mybe i'll do some other test , but if you want is not difficoult to have the error
you must write the service like mine and the OnInitializedAsync() like mine
THX for all !!!!!
Hi Francesco,
Thank you for the update. If you encounter any further issues, feel free to reach out to us.
Regards,
Ajithkumar G
- 5 Replies
- 2 Participants
-
FP Francesco Pruneri
- Jan 7, 2024 10:34 AM UTC
- Jan 11, 2024 01:47 PM UTC