<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Copy and store the default model in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682809#M181552</link>
    <description>&lt;P&gt;I don't understand really well what are you trying to ask...&lt;BR /&gt;&lt;BR /&gt;But I'm gonna play... I think that the problem is in new JSONModel:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;this.getView().setModel(new JSONModel(copyModel)); 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What is DATA? Json model? oData Model? &lt;/P&gt;</description>
    <pubDate>Fri, 28 Sep 2018 09:53:06 GMT</pubDate>
    <dc:creator>jorge_cabanas</dc:creator>
    <dc:date>2018-09-28T09:53:06Z</dc:date>
    <item>
      <title>Copy and store the default model</title>
      <link>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaq-p/682808</link>
      <description>&lt;P&gt;Hi, I have a created a default model and when I start my application, I want to copy it to a second model and then use it in a different function to reset everything. Here what I have done, on my InitFunction: &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;console.log("Data ", data);
copyModel = $.extend({}, data);&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Data is my original model. I have declared the copyModel as a global variable.&lt;/P&gt;
  &lt;P&gt;Then I have the resetFunction:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;resetP: function(){
this.getView().setModel(new JSONModel(copyModel));&lt;BR /&gt;console.log("CopyModel ", copyModel);
}
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The code seems to run, but I have a weird problem. When I first click the reset Button, copyModel is same with the original model (data). The second time I ran the resetFunction, copyModel is not the same with the original. It has been overwritten with the existing one the moment I press the button. Can anyone help me with that? Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2018 08:36:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaq-p/682808</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-09-28T08:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and store the default model</title>
      <link>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682809#M181552</link>
      <description>&lt;P&gt;I don't understand really well what are you trying to ask...&lt;BR /&gt;&lt;BR /&gt;But I'm gonna play... I think that the problem is in new JSONModel:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;this.getView().setModel(new JSONModel(copyModel)); 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What is DATA? Json model? oData Model? &lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2018 09:53:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682809#M181552</guid>
      <dc:creator>jorge_cabanas</dc:creator>
      <dc:date>2018-09-28T09:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and store the default model</title>
      <link>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682810#M181553</link>
      <description>&lt;P&gt;Yes, data is my original JSON model from a form which is being created when I first open my app. I want to have a copy of this model for using it when I am resetting my form. The problem is that at first I keep a right copy and when I run the reset function for a second time, the copy of the model is changed.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2018 12:46:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682810#M181553</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-09-28T12:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and store the default model</title>
      <link>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682811#M181554</link>
      <description>&lt;P&gt;try cloning the original object like this instead of the $.extend function&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var copyObject = JSON.parse(JSON.stringify(originalObject));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Sep 2018 12:53:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682811#M181554</guid>
      <dc:creator>SergioG_TX</dc:creator>
      <dc:date>2018-09-28T12:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and store the default model</title>
      <link>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682812#M181555</link>
      <description>&lt;P&gt;It should work because the pointer is not assigned in this way. So when the original data is modified (whenever), the copy will never be modified.&lt;BR /&gt;Good point.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 06:53:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682812#M181555</guid>
      <dc:creator>jorge_cabanas</dc:creator>
      <dc:date>2018-10-01T06:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copy and store the default model</title>
      <link>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682813#M181556</link>
      <description>&lt;P&gt;Unfortunately, none of these two ways worked. As it's written on Stackoverflow and works for me:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resetP: function(){
this.getView().getModel().updateBindings();
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 08:09:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/copy-and-store-the-default-model/qaa-p/682813#M181556</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-10-01T08:09:52Z</dc:date>
    </item>
  </channel>
</rss>

