How Do I Get Layout Xml from Client-side Javascript?

Posted by: trail-hacker on 3 August 2017, 3:54 pm EST

  • Posted 3 August 2017, 3:54 pm EST

    Is it possible to serialize the PivotViews' layout from inside Javascript? I'm doing this via a jquery hack right now where I simply find the control and call the click() method like so:
    $("#saveLayoutButton")click(function(){

      var layoutName = prompt('Enter a name for this layout:');
      if (layoutName == '')
         return;

      $("#layoutNameTextbox").val(layoutName);
      $("#
    connectionKeyTextbox").val('<%= Model.ConnectionKey %>');
      $("#buttonSave").click(); // jQuery hack! :(

    });

    Now I've run into a situation where I need access the layouts' Xml via javascript. Currently, I'm forced to use the server-side Click() event trap, where buttonSave is defined with runat="server" like this:

    protected void buttonSave_Click(object sender, EventArgs e)
    {
       var layout = new Layout(connectionKeyTextbox.Text);
       layout.Name = layoutNameTextbox.Text;
       layout.Xml = GetPivotViewXml();

       _repository.AddLayout(layout);
       _repository.Save();
    }

    However, I need to be able to read the PivotViews' state in my javascript and post it to the server like this instead:
    $("#saveLayoutButton")click(function(){

     
    var newLayout =
      {
       ConnectionKey: '<%= Model.ConnectionKey %>',
       LayoutName: $('#layoutNameTextbox').val(),
       LayoutXml: getPivotViewXml() // What goes here?
      };

      $.post('/Layouts/Create',
       newLayout,
       function(data){
          alert("Your layout was saved.");     
          currentLayoutKey = data.LayoutKey;
          refreshLayoutsCombo();
       },
       "json"
      );

    });
    Is there any trick to get the the PivotViews' Xml from javascript?

    Thank you in advance for any help.
  • Replied 3 August 2017, 3:54 pm EST

    Hello,



    I would like to inform you that it is not possible to retrieve PivotView XML from via JavaScript. The layout can be retrieved only on the server side. We are planning to provide a Silverlight version of DataDynamics Analysis soon and then we can implement such functionality. Until then this is not possible with the current API.

    Thanks,

    Gaurav

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels