Export to XML

Hi

I've previously created a thread asking about this, but made it for EJ 2 in error, this is the thread: https://www.syncfusion.com/support/directtrac/incidents/236937
I've tried implementing the solution provided there, but I'm unable to get it working. Is there a different way of implementing XML export for EJ 1?

The implementation breaks class: "XmlImportingHelper.Gantt", method: "ConvertGanttObject" line 102: 
Error message: System.FormatException: 'stringedit is not a valid value for TreeGridEditingType.'


        private GanttProperties ConvertGanttObject(string ganttModel)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            serializer.MaxJsonLength = Int32.MaxValue;
            IEnumerable div = (IEnumerable)serializer.Deserialize(ganttModel, typeof(IEnumerable));
            GanttProperties ganttProp = new GanttProperties();
            foreach (KeyValuePair<string, object> ds in div)
            {
                var property = ganttProp.GetType().GetProperty(ds.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
                if (property != null)
                {
                    Type type = property.PropertyType;
                    string serialize = serializer.Serialize(ds.Value);
                    object value ;
                    if (ds.Key == "dataSource")
                    {
                        value = serializer.Deserialize<List<BusinessObject>>(serialize);
                    }
                    else if (ds.Key == "resources")
                    {
                        value = serializer.Deserialize<List<GanttResources>>(serialize);
                    }
                    else
                    {
                        value = serializer.Deserialize(serialize, type); // Breaks here
                    }
                    property.SetValue(ganttProp, value, null);
                }
            }
            return ganttProp;
        }

1 Reply

PP Pooja Priya Krishna Moorthy Syncfusion Team April 22, 2020 09:19 AM UTC

Hi Martin, 
We are able to reproduce the reported issue. We have fixed the reported issue, by changing the edit type value based on the value defined in TreeGridEditingType as like below code example. 
[XMLIMportExportHelper.js] 
function xmlExport(action) { 
//... 
 var columns = ganttObjFinal.columns, 
      columnLength = columns.length; 
  for (var i = 0; i < columnLength; i++) { 
        if (columns[i].editType !== undefined) { 
            switch (columns[i].editType) { 
                case "stringedit": 
                    columns[i].editType = "string"; 
                    break; 
                case "numericedit": 
                    columns[i].editType = "numeric"; 
                    break; 
                //... 
            } 
        } 
    } 
   //... 
} 
 
We also facing some other problems, while processing the record collection during Export action. We have also fixed that issue in XMLIMportExportHelper.js file. You can get the runnable sample from below link 
 
You can use the same web service and helper methods shared in another incident. For your convenient, we are sharing the same here. 

Please get back to us if you would require further assistance on this. 

Regards, 
Pooja K. 


Loader.
Up arrow icon