Skip to Content

How to set templateShareable while/before cloning

Hi Experts,

In the controller.js, i have written a clone statement like this:

var oView = that.getView().byId("aggregatedView").clone(); // i need a cloning here to avoid loosing the existing binding

oView.bindItems({
path: "/ZEntity",
template: that.getView().byId("aggregatedViewItems"),
filters: aFilters });

I am receiving an error as described here:

During a clone operation, a template was found that neither was marked with 'templateShareable:true' nor 'templateShareable:false'. https://sapui5.hana.ondemand.com/sdk/#docs/guide/3a4a9e562988456c9be0ef883ae7da50.html


I know i have to set templateShareable to either false or true somewhere(i dont know where exactly).

I tried setting in the XML view like this: it did not work

<items>

<core:Item id="aggregatedViewItems" key="{Key1}" text="{Text1}" templateShareable="false"/>

</items>

Can somebody help me with syntax how i can set templateShareable within/before this statement: var oView = that.getView().byId("aggregatedView").clone();

BR,
Venky.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • Best Answer
    Mar 01, 2017 at 05:52 AM

    Hi Guys,

    Thanks for your help.

    I could fix it by setting templatesharable in the XML view itself.

    Earlier the code was like this:

    <ActionSelect id="aggregatedView" items="{ path: '/Zentity' }" maxWidth="20em" change="handleSwitchProcess" > <items>
    <core:Item id="aggregatedViewItems" key="{Key1}" text="{text1}" />
    </items>
    </ActionSelect>

    After fixing, it became:

    <ActionSelect id="aggregatedView" items="{ path: '/Zentity', templateShareable:false }" maxWidth="20em" change="handleSwitchProcess" > <items>
    <core:Item id="aggregatedViewItems" key="{Key1}" text="{text1}" />
    </items>
    </ActionSelect>

    BR,
    Venky.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 01, 2017 at 05:52 AM

    Hi Guys,

    Thanks for your help.

    I could fix it by setting templatesharable in the XML view itself.

    Earlier the code was like this:

    <ActionSelect id="aggregatedView" items="{ path: '/Zentity' }" maxWidth="20em" change="handleSwitchProcess" > <items>
    <core:Item id="aggregatedViewItems" key="{Key1}" text="{text1}" />
    </items>
    </ActionSelect>

    After fixing, it became:

    <ActionSelect id="aggregatedView" items="{ path: '/Zentity', templateShareable:false }" maxWidth="20em" change="handleSwitchProcess" > <items>
    <core:Item id="aggregatedViewItems" key="{Key1}" text="{text1}" />
    </items>
    </ActionSelect>

    BR,
    Venky.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 28, 2017 at 06:10 AM

    why you want to clone?

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 28, 2017 at 06:11 AM

    why you want to clone?

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 28, 2017 at 05:42 PM

    Hello Venky,

    This is the jsdoc for binding aggregation .

    As you would templateShareable is also a parameter in the binding. So your binding would be essentially be

    oView.bindItems({ path: "/ZEntity", template: that.getView().byId("aggregatedViewItems"), filters: aFilters ,templateShareeable : true/false });               

    I hope this helps.

    Thanks and Regards,

    Veera


    Add comment
    10|10000 characters needed characters exceeded

  • Feb 28, 2017 at 05:50 PM

    Hello Venky,

    As attached here , this is jsdoc for aggregation binding

    o your code would be

    oView.bindItems({ path: "/ZEntity", template: that.getView().byId("aggregatedViewItems"), filters: aFilters ,templateShareable : true/false});

    Hope this helps.

    Thanks and Regards,

    Veera

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Veera,

      Thanks for the help.

      I tried your suggestion, but the error is occuring at this statement itself:

      var oView = that.getView().byId("aggregatedView").clone()

      So, i need to set this 'templateShareable ' before i perform the clone() operation in the above statement, is it possible ?

      Best Regards,
      Venky.