BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hello,
Finally, I found where root caused the error. I took your sample and made a few modification (I will be posted code below). Because our project required a dropdown field in a custom column, so I manually created and populated its data on Gantt load function. Then I tried the export PDF/Excel, it gave me errors below accordingly PDF or Excel exports.
PDF export:
System.ArgumentOutOfRangeException: 'The added or subtracted value results in an un-representable DateTime.'
Excel export:
System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values.'
ASPX:
<asp:Content ID="content" runat="server" ContentPlaceHolderID="MainContent"> <script src='<%=Page.ResolveClientUrl("~/Scripts/Gantt/TaskInfo.js") %>'></script> <ej:Gantt runat="server" ID="GanttControlExporting" ChildMapping="Children" TreeColumnIndex="1" IsResponsive="true" ParentTaskIdMapping="ParentId" TaskIdMapping="TaskId" TaskNameMapping="TaskName" StartDateMapping="StartDate" EndDateMapping="EndDate" DurationUnit="Day" DateFormat="M/d/yyyy" DurationMapping="Duration" ProgressMapping="Progress" ResourceIdMapping="ResourceId" ResourceNameMapping="ResourceName" PredecessorMapping="Predecessor" ShowProgressStatus="true" ShowColumnChooser="true" SplitterPosition="95%" AllowGanttChartEditing="false" EnableContextMenu="true" AllowColumnResize="true" AllowSorting="false" AllowMultiSorting="true" IncludeWeekend="false" HighlightWeekends="true" EnableWBS="true" EnableWBSPredecessor="false" Load="load" OnServerPdfExporting="GanttControlExporting_ServerPdfExporting" OnServerExcelExporting="GanttControlExporting_ServerExcelExporting"> <EditSettings AllowDeleting="true" AllowEditing="true" AllowAdding="true" AllowIndent="true" EditMode="cellEditing" /> <SizeSettings Width="100%" Height="450px" /> <ToolbarSettings ShowToolbar="true" ToolbarItems="add,edit,delete,update,cancel,indent,outdent,expandAll,collapseAll,pdfExport,excelExport" /> </ej:Gantt> <script type="text/x-jsrender" id="investigateColumnTemplate1"> <div style="margin-left: 20px;"> {{if Investigate}} <input class="customCheckbox" type="checkbox" disabled="disabled" checked="checked" value="" />{{else}} <input class="customCheckbox" type="checkbox" disabled="disabled" value="" />{{/if}} </div> </script> <script type="text/x-jsrender" id="WbsColumnTemplate"> <div> {{:~WBS}} </div> </script> <script type="text/javascript"> function load(args) { var columns = this.getColumns(); var col1 = { field: "ResourceName", headerText: "Resource", editType: "stringedit", mappingName: "ResourceName" }, col2 = { field: "TeamName", headerText: "Team", mappingName: "TeamName", editType: "dropdownedit", dropdownData: null, editParams: { fields: { text: "TeamName", value: "TeamName" }, showCheckbox: false }, width: "80px" }, col3 = { field: "ParentId", headerText: "Parent", mappingName: "ParentId", editType: "numericedit", width: "57px" }, investCol = { field: "Investigate", headerText: "Investigate", mappingName: "Investigate", editType: "booleanedit", isTemplateColumn: true, templateID: "investigateColumnTemplate1", width: "55px" }, wbsCol = { field: "WBS", headerText: "WBS", width: 75, allowEditing: false, mappingName: "WBS" }; columns.splice(2, 0, col1); columns.splice(4, 0, col2); columns.splice(6, 0, col3); columns.splice(7, 0, investCol); columns.splice(11, 1); columns.splice(11, 0, wbsCol);
TaskInfo.getTeams(function (result) { columns[4].dropdownData = result; //JSON retur }); } </script> </asp:Content>
.CS Code behind
protected void Page_Load(object sender, EventArgs e) { // var DataSource = this.GetDataSource(); var DataSource = GetTaskSource(); this.GanttControlExporting.DataSource = DataSource; this.GanttControlExporting.DataBind(); }
private List<TaskData> GetTaskSource() {
// get task from database here
}
protected void GanttControlExporting_ServerPdfExporting(object sender, Syncfusion.JavaScript.Web.GanttEventArgs e) { PdfExport exp = new PdfExport(); GanttPdfExportSettings settings = new GanttPdfExportSettings(); settings.IncludeTemplateColumn = true; settings.EnableFooter = true; settings.ProjectName = "Project Tracker"; settings.Locale = e.Arguments["locale"].ToString(); settings.Theme = GanttExportTheme.FlatLime; exp.Export(this.GanttControlExporting.Model, (IEnumerable)this.GanttControlExporting.DataSource, settings, "Gantt"); } protected void GanttControlExporting_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GanttEventArgs e) { ExcelExport exp = new ExcelExport(); GanttExportSettings settings = new GanttExportSettings(); settings.Theme = ExportTheme.FlatLime; exp.Export(this.GanttControlExporting.Model, (IEnumerable)this.GanttControlExporting.DataSource, "Export.xlsx", ExcelVersion.Excel2010, new GanttExportSettings() { Theme = ExportTheme.FlatLime }); }
public class TaskData { public int ProjectId { get; set; } public string StartDate { get; set; } public string EndDate { get; set; } public int TaskId { get; set; } public int ParentId { get; set; } public string TaskName { get; set; }
public int Duration { get; set; } public int Progress { get; set; } public int PercentDone { get; set; }public string Predecessor { get; set; } public string WBS { get; set; }public string ResourceName { get; set; }public string TeamId { get; set; }public string TeamName { get; set; }public bool Investigate {get; set;}}
[TaskInfo.asmx.cs]
public object GetTeams()
{
//…
var jsonSerialiser = new JavaScriptSerializer();
var teamData = jsonSerialiser.Serialize(teamDataCollection);
return teamData;
} |
[TaskInfo.js]
var getTeams = function (callback) {
// get Teams
$.ajax({
type: 'GET',
async: false,
//…
success: function (result) {
callback(JSON.parse(result.d));
}, |