[CLOSED] Send multiple charts to server for printing

  1. #1

    [CLOSED] Send multiple charts to server for printing

    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.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
       at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
       at Newtonsoft.Json.JsonConvert.DeserializeObject(String 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(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    Last edited by Daniil; Dec 11, 2014 at 7:43 AM. Reason: [CLOSED]
  2. #2
    Hi @jchau,

    This example might help you.
    https://examples2.ext.net/#/Chart/Mi...ge_Two_Charts/
  3. #3
    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.
  4. #4
    What about to use array as direct method argument?
  5. #5
    I just tried an array. It throws an Exception on serialization. I am investigating how to get rid of that.
  6. #6
    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.surface),
                    Ext.draw.engine.SvgExporter.generate(App.Chart2.surface)
                ];
    
                App.direct.ExportTwoSvg(Ext.htmlEncode(Ext.encode(svgs)), { isUpload: true });
            }
        });
    };
    [DirectMethod]
    public void ExportTwoSvg(string jsonSvgs)
    {
        string[] svgs = JSON.Deserialize<string[]>(Server.HtmlDecode(jsonSvgs));
        string svg1 = svgs[0];
        string svg2 = svgs[1];
       
        ...
    }
  7. #7
    Thanks! I will give that a try.

Similar Threads

  1. [CLOSED] Gridpanel: send selected data to server
    By tanky65 in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 13, 2013, 9:49 PM
  2. [CLOSED] Field outside of Form panel is not send to server
    By aisi_it_admin in forum 2.x Legacy Premium Help
    Replies: 10
    Last Post: Aug 22, 2012, 5:27 PM
  3. Send gridpanel settings to server
    By plykkegaard in forum 1.x Help
    Replies: 1
    Last Post: Dec 06, 2010, 8:03 PM
  4. Replies: 1
    Last Post: May 05, 2010, 1:47 PM
  5. Replies: 1
    Last Post: Jun 09, 2009, 3:06 PM

Posting Permissions