如果您熟悉Visual Studio 2012 ASP.NET C#中的Syncfusion甘特图。
我在Visual Studio 2012中使用了Syncfusion Gantt Chart,但是当我使用IE查看时,甘特图无法显示。
Default.aspx的
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.App_web.WebForm2" %>
<%@ Register Assembly="Syncfusion.EJ.Web, Version=12.3450.0.36, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Web" TagPrefix="ej" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<ej:Gantt ID="GanttControlDefault" runat="server" AllowSelection="true" AllowColumnResize="true"
TaskIdMapping="Id" TaskNameMapping="Name" ScheduleStartDate="02/23/2014" ScheduleEndDate="03/10/2014"
StartDateMapping="StartDate" EndDateMapping="EndDate" ProgressMapping="PercentDone"
ChildMapping="Children" AllowGanttChartEditing="false"
TreeColumnIndex="1">
</ej:Gantt></asp:Content>
背后的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Syncfusion.JavaScript.Web;
using Syncfusion.EJ;
using Syncfusion.Core;
using Syncfusion.Web;
namespace WebApplication1.App_web
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//var DataSource = this.GetDataSource();
this.GanttControlDefault.DataSource = GetDataSource();
this.GanttControlDefault.DataBind();
}
#region Create DataSource for Default Gantt control
private List<BusinessObject> GetDataSource()
{
List<BusinessObject> list = new List<BusinessObject>();
list.Add(new BusinessObject()
{
Id = 1,
Name = "Parent Task 1",
StartDate = "02/23/2014",
EndDate = "02/27/2014",
PercentDone = "40",
Children = (new List<BusinessObject>()
{
new BusinessObject()
{
Id = 2,
Name = "Child Task 1",
StartDate = "02/23/2014",
EndDate="02/27/2014",
PercentDone = "40",
},
new BusinessObject()
{
Id = 3,
Name = "Child Task 2",
StartDate = "02/23/2014",
EndDate="02/27/2014",
PercentDone = "40"
},
new BusinessObject()
{
Id = 4,
Name = "Child Task 3",
StartDate = "02/23/2014",
EndDate="02/27/2014",
PercentDone = "40"
}
})
});
list.Add(new BusinessObject()
{
Id = 5,
Name = "Parent Task 2",
StartDate = "03/14/2014",
EndDate = "03/18/2014",
PercentDone = "40",
Children = (new List<BusinessObject>()
{
new BusinessObject()
{
Id = 6,
Name = "Child Task 1",
StartDate = "03/02/2014",
EndDate="03/06/2014",
PercentDone = "40",
},
new BusinessObject()
{
Id = 7,
Name = "Child Task 2",
StartDate = "03/02/2014",
EndDate="03/06/2014",
PercentDone = "40",
},
new BusinessObject()
{
Id = 8,
Name = "Child Task 3",
StartDate = "03/02/2014",
EndDate="03/06/2014",
PercentDone = "40",
},
new BusinessObject()
{
Id = 9,
Name = "Child Task 4",
StartDate = "03/02/2014",
EndDate="03/06/2014",
PercentDone = "40",
}
})
});
list.Add(new BusinessObject()
{
Id = 10,
Name = "Parent Task 3",
StartDate = "03/09/2014",
EndDate = "03/13/2014",
PercentDone = "40",
Children = (new List<BusinessObject>()
{
new BusinessObject()
{
Id = 11,
Name = "Child Task 1",
StartDate = "03/9/2014",
EndDate="03/13/2014",
PercentDone = "40"
},
new BusinessObject()
{
Id = 12,
Name = "Child Task 2",
StartDate = "03/9/2014",
EndDate="03/13/2014",
PercentDone = "40",
},
new BusinessObject()
{
Id = 13,
Name = "Child Task 3",
StartDate = "03/9/2014",
EndDate="03/13/2014",
PercentDone = "40"
},
new BusinessObject()
{
Id = 14,
Name = "Child Task 4",
StartDate = "03/9/2014",
EndDate="03/13/2014",
PercentDone = "40"
},
new BusinessObject()
{
Id = 15,
Name = "Child Task 5",
StartDate = "03/9/2014",
EndDate="03/13/2014",
PercentDone = "40"
}
})
});
return list;
}
#endregion
#region BusinessObject Creation
public class BusinessObject
{
public string StartDate { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public string EndDate { get; set; }
public string PercentDone { get; set; }
public List<object> ResourceID { get; set; }
public List<BusinessObject> Children { get; set; }
public string Predescessor { get; set; }
}
#endregion
}
}
答案 0 :(得分:1)
您在ASPX和ASPX.CS文件中为包含控件和数据源所做的更改很好,您还可以确保web.config文件包含必要的Syncfusion dll的更改,
[web.config]
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="Syncfusion.EJ.Web, Version= XX.XXXX.X.XX, Culture=neutral, PublicKeyToken=3D67ED1F87D44C89"/>
<add assembly="Syncfusion.EJ, Version= XX.XXXX.X.XX, Culture=neutral, PublicKeyToken=3D67ED1F87D44C89"/>
</assemblies>
</compilation>
确保已引用以下外部和内部脚本文件以呈现甘特图控件
<link href="Content/ej/ej.widgets.core.min.css" rel="stylesheet" />
<link href="Content/ej/flat-lime/ej.theme.min.css" rel="stylesheet" />
<script src='<%= Page.ResolveClientUrl("~/Scripts/jquery-1.10.2.min.js")%>' type="text/javascript"></script>
<script src='<%= Page.ResolveClientUrl("~/Scripts/jsrender.min.js")%>' type="text/javascript"></script>
<script src='<%= Page.ResolveClientUrl("~/Scripts/jquery.easing-1.3.min.js")%>' type="text/javascript"></script>
<script src='<%= Page.ResolveClientUrl("~/Scripts/jquery.globalize.min.js")%>' type="text/javascript"></script>
<script src='<%= Page.ResolveClientUrl("~/Scripts/ej.web.all.min.js")%>' type="text/javascript"></script>
另请参阅联机文档link,以便使用Syncfusion控件创建ASP.NET C#应用程序。
由于