C1GanttView左侧树结点的逐级加载
本帖最后由 86971375 于 2022-9-20 10:08 编辑C1GanttView左侧树结点的逐级加载,因为内容太多了导致加载数据太慢,加急。
目前不支持逐级加载这种方式,仅提供一次性加载 本帖最后由 86971375 于 2022-9-20 15:23 编辑
我的数据只有不到200条,但是加载速度太慢了,下面是我的代码,麻烦看看
/// <summary>
/// 加载根级节点数据集
/// </summary>
/// <param name="Id"></param>
private void BulidTaskInfo()
{
GanttView1.Tasks.Clear();
GanttView1.StartDate = ucStartDate.Value.Date;
GanttView1.FinishDate = ucEndDate.Value.Date;
Guid Pid = Guid.Empty;
var rootList = myBll.GetProjectPlanDetailList(MyModel.Id,Guid.Empty);//xmmxList.OrderBy(p => p.StartDate).ThenBy(p => p.SerialNumber);
foreach (var item in rootList)
{
C1.Win.C1GanttView.Task task = new C1.Win.C1GanttView.Task();
task.ID = item.Id.GetHashCode();
task.Name = item.WorkContent;
task.Notes = item.WorkingRrules;
task.Start = item.StartDate.Date;
task.Finish = item.EndDate.Date;
task.Mode = TaskMode.Manual;
#region old
//TimeSpan daysSpan = new TimeSpan(item.EndDate.Date.Ticks - item.StartDate.Date.Ticks);
//task.Duration = daysSpan.Days;
//task.DurationUnits= DurationUnits.Days;
//任务完成百分比
//task.PercentComplete = 0;
//task.ConstraintType = ConstraintType.Default;
//task.ConstraintDate = item.EndDate;
#endregion
//自定义列
task.SetFieldValue("KeyId", item.Id);
task.SetFieldValue("HandlerMan", item.HandlerMan);
task.SetFieldValue("PID", item.PID);
task.SetFieldValue("HandlerName", item.HandlerName);
task.OutlineParentID = 399205711;
GanttView1.Tasks.Add(task);
//xmmxList.Where(p => p.PID == item.Id).OrderBy(p => p.StartDate).ThenBy(p => p.SerialNumber).ToList();
var childList = myBll.GetProjectPlanDetailList(MyModel.Id,item.Id);
if (childList.Any())
{
BulidChildTaskInfo(task, childList, item.Id);
}
}
CollapseGroupTasks(true);
//C1.Win.C1GanttView.Task t = GanttView1.Tasks.Search("First Task");
//GanttView1.ScrollToTask(t);
//GanttView1.SelectedTask = t;
}
/// <summary>
///获取某个任务的子任务信息
/// </summary>
/// <param name="taskList"></param>
/// <param name="Id">父节点</param>
/// <param name="durationUnits">图形显示单位:0Minutes,1Hours,2Days,3Weeks,4Months</param>
/// <returns></returns>
private void BulidChildTaskInfo(C1.Win.C1GanttView.Task masterTask, List<JHGLGTT_ProjectPlanDetail> childList, Guid Id)
{
foreach (var item in childList)
{
C1.Win.C1GanttView.Task task1 = GanttView1.Tasks.AddNew();
task1.ID = item.Id.GetHashCode();
task1.Name = item.WorkContent;
task1.Notes = item.WorkingRrules;
task1.Start = item.StartDate.Date;
task1.Finish = item.EndDate.Date;
task1.Mode = TaskMode.Manual;
#region old
//TimeSpan daysSpan = new TimeSpan(item.EndDate.Date.Ticks - item.StartDate.Date.Ticks);
//task1.Duration = daysSpan.Days;
//task1.DurationUnits = durationUnits;
//完成百分比
//task1.PercentComplete = 0;
//task1.ConstraintType = ConstraintType.Default;
//task1.ConstraintDate = item.StartDate;
#endregion
//自定义列
task1.SetFieldValue("KeyId", item.Id);
task1.SetFieldValue("HandlerMan", item.HandlerMan);
task1.SetFieldValue("PID", item.PID);
task1.SetFieldValue("HandlerName", item.HandlerName);
task1.OutlineParentID = masterTask.ID;
//xmmxList.Where(p => p.PID == item.Id).OrderBy(p => p.StartDate).ThenBy(p => p.SerialNumber).ToList();
var taskList0 = myBll.GetProjectPlanDetailList(MyModel.Id,item.Id);
if (taskList0.Any())
{
BulidChildTaskInfo(task1, taskList0, item.Id);
}
if (task1 != null)
{
masterTask.AddChild(task1);
//GanttView1.Tasks.Add(task1);
}
}
}
你上传一个能重现问题的demo上来看看吧 附件里面是我的数据(SQL脚本),麻烦你给看一下,着急的很
这个没有办法验证啊:'(
麻烦还是上传一个能直接运行的demo上来,如果是控件产品的问题,也需要给研发提bug
自己把问题已解决了,谢谢 :hjyzw:,问题解决了就行,也欢迎分享一下问题的原因 数据缓存内存中。 好的,那看来主要还是源数据获取的速度慢导致的,感谢分享
页:
[1]