View Full Version : [CLOSED] Send multiple charts to server for printing

Dec 04, 2014, 5:33 PM
We have a dashboard with multiple charts. How can I send multiple SVGs back to the server? I get json serialization errors if I try to do List<string> as the parameter type. In your print chart example, you are only sending one SVG back as string type.

Newtonsoft.Json.JsonReaderException: After parsing a value an unexpected character was encountered: 1. Path '[0]', line 1, position 17. at Newtonsoft.Json.JsonTextReader.ParsePostValue()
at Newtonsoft.Json.JsonTextReader.ReadInternal()
at Newtonsoft.Json.JsonReader.ReadAsStringInternal()
at Newtonsoft.Json.JsonTextReader.ReadAsString()
at Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(Stri ng value, Type type, JsonSerializerSettings settings)
at Ext.Net.JSON.Deserialize(String value, Type type, IList`1 converters, IContractResolver resolver)
at Ext.Net.DirectMethod.Invoke(Object target, HttpContext context, ParameterCollection args)
at Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Dec 04, 2014, 8:26 PM
Hi @jchau,

This example might help you.

Dec 04, 2014, 10:36 PM
Thanks, but I looked at that example before too. It works because the directmethod is hardcoded to accept two SVGs. For my page, there can be N number of charts.

Dec 05, 2014, 6:22 AM
What about to use array as direct method argument?

Dec 05, 2014, 6:38 AM
I just tried an array. It throws an Exception on serialization. I am investigating how to get rid of that.

Dec 05, 2014, 7:06 AM
This appears to be working.

var exportTwoCharts = function (btn) {
Ext.MessageBox.confirm('Confirm Download', 'Would you like to upload the chart to the server?', function (choice) {
if (choice == 'yes') {
var svgs = [
Ext.draw.engine.SvgExporter.generate(App.Chart1.su rface),
Ext.draw.engine.SvgExporter.generate(App.Chart2.su rface)

App.direct.ExportTwoSvg(Ext.htmlEncode(Ext.encode( svgs)), { isUpload: true });

public void ExportTwoSvg(string jsonSvgs)
string[] svgs = JSON.Deserialize<string[]>(Server.HtmlDecode(jsonSvgs));
string svg1 = svgs[0];
string svg2 = svgs[1];


Dec 05, 2014, 1:27 PM
Thanks! I will give that a try.