<?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: Replacing image dynamically in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/replacing-image-dynamically/qaa-p/12608197#M4728795</link>
    <description>&lt;P&gt;The key thing here is that you cannot directly modify the section like you are trying to do in the rule.&lt;/P&gt;&lt;P&gt;You will want to probably need use a rule for the Image property in the image section.  This rule will check if you have selected a different image or should display the default image (from the default binding which I assume would be a product detail page).&lt;/P&gt;&lt;P&gt;You logic for determining the new image path reference is fine you just need to store it in a temp location (I would suggest the page level client data) so when you redraw the image section it can get the updated path reference.&lt;/P&gt;&lt;P&gt;You can redraw just the image section using imageControl.redraw(); but keep in mind that the size of the section will not automatically adjust on redraw.  This is something we should investigate for a future enhancements.  If you want to also have the section size change you will need to redraw the whole page using pageProxy.redraw().&lt;/P&gt;</description>
    <pubDate>Mon, 24 Oct 2022 05:16:34 GMT</pubDate>
    <dc:creator>bill_froelich</dc:creator>
    <dc:date>2022-10-24T05:16:34Z</dc:date>
    <item>
      <title>Replacing image dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/replacing-image-dynamically/qaq-p/12608196</link>
      <description>&lt;P&gt;I am new with MDK and having some issues with trying to implement this feature. &lt;/P&gt;
  &lt;P&gt;I have an image on a section.type.image and want to replace it with an image that is clicked from section.type.imagecollection. I am using odata.readLink/$value to display the images on the section.type.imagecollection and for the section.type.image the image value odata.readLink/$value is passed from a product image being clicked on product details page. &lt;/P&gt;
  &lt;P&gt;oData version 2.0&lt;/P&gt;
  &lt;P&gt;Offline App&lt;/P&gt;
  &lt;P&gt;This is the rule that I have written and has some of the steps I have tried commented out&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;export default function ImageSelection(clientAPI) {&lt;BR /&gt;    const pageProxy = clientAPI.getPageProxy();&lt;BR /&gt;    const bindingObject = pageProxy.getActionBinding();&lt;BR /&gt;   let imageControl = clientAPI.getPageProxy().getControl('SectionedTable0').getSection('ImageSection0');&lt;BR /&gt;let imageVal = bindingObject['@odata.readLink'] + '/$value';&lt;BR /&gt;let imageValMedia = "/PracticeV_1/Services/SampleServiceV2.service/" + bindingObject["@odata.mediaReadLink"]&lt;BR /&gt;imageControl["@odata.mediaReadLink"] = imageValMedia;&lt;BR /&gt;imageControl.binding.PictureUrl = bindingObject.PictureUrl;&lt;BR /&gt;//imageControl.binding["@odata.mediaReadLink"] = imageValMedia;&lt;BR /&gt;//imageControl.binding["@odata.mediaEditLink"] = imageValMedia;&lt;BR /&gt;//imageControl.redraw();&lt;BR /&gt;//pageProxy.redraw();&lt;BR /&gt;}&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;here is the modal page with the said metadata&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;{&lt;BR /&gt;    "Caption": "EditProduct_Image",&lt;BR /&gt;    "Controls": [&lt;BR /&gt;        {&lt;BR /&gt;            "Sections": [&lt;BR /&gt;                {&lt;BR /&gt;                    "_Type": "Section.Type.Image",&lt;BR /&gt;                    "_Name": "ImageSection0",&lt;BR /&gt;                    "Alignment": "center",&lt;BR /&gt;                    &lt;BR /&gt;                    "Image": "/PracticeV_1/Services/SampleServiceV2.service/{@odata.readLink}/$value",&lt;BR /&gt;                    "ContentMode": "ScaleAspectFit",&lt;BR /&gt;                    "Header": {&lt;BR /&gt;                        "Caption": "{Name}"&lt;BR /&gt;                    }&lt;BR /&gt;                },&lt;BR /&gt;                {&lt;BR /&gt;                    "_Type": "Section.Type.ImageCollection",&lt;BR /&gt;                    "_Name": "ImageCollectionSec",&lt;BR /&gt;                    "ImageCell": {&lt;BR /&gt;                        "Image": "/PracticeV_1/Services/SampleServiceV2.service/{@odata.readLink}/$value",&lt;BR /&gt;                        "OnPress": "/PracticeV_1/Rules/ImageEdit/ImageSelection.js"&lt;BR /&gt;                    &lt;BR /&gt;                    },&lt;BR /&gt;                    "Layout": {&lt;BR /&gt;                        "LayoutType": "HorizontalScroll"&lt;BR /&gt;                    },&lt;BR /&gt;                    "Target":{&lt;BR /&gt;                        "EntitySet": "Products",&lt;BR /&gt;                        "Service": "/PracticeV_1/Services/SampleServiceV2.service",&lt;BR /&gt;                         "QueryOptions": "$orderby=Name&amp;amp;$top=16"&lt;BR /&gt;                    },&lt;BR /&gt;                    "Header": {&lt;BR /&gt;                        "Caption": "Select Existing Image"&lt;BR /&gt;                    }&lt;BR /&gt;                },&lt;BR /&gt;                {&lt;BR /&gt;                    "_Type": "Section.Type.FormCell",&lt;BR /&gt;                    "_Name": "FormSection",&lt;BR /&gt;                    "Controls": &lt;BR /&gt;                    [&lt;BR /&gt;                        {&lt;BR /&gt;                            "_Type": "Control.Type.FormCell.Attachment",&lt;BR /&gt;                            "_Name": "Attachment",&lt;BR /&gt;                            "AttachmentActionType": [&lt;BR /&gt;                                "TakePhoto",&lt;BR /&gt;                                "AddPhoto"&lt;BR /&gt;                            ]&lt;BR /&gt;&lt;BR /&gt;                        }&lt;BR /&gt;                        &lt;BR /&gt;                    ],&lt;BR /&gt;                    "Header": {&lt;BR /&gt;                        "Caption": "Upload Image"&lt;BR /&gt;                    }&lt;BR /&gt;                }&lt;BR /&gt;            ],&lt;BR /&gt;            "_Name": "SectionedTable0",&lt;BR /&gt;            "_Type": "Control.Type.SectionedTable"&lt;BR /&gt;        }&lt;BR /&gt;    ],&lt;BR /&gt;    "_Name": "EditProduct_Image",&lt;BR /&gt;    "_Type": "Page",&lt;BR /&gt;    "ActionBar": {&lt;BR /&gt;        &lt;BR /&gt;        "Items":[&lt;BR /&gt;            {&lt;BR /&gt;                "_Name": "Cancel",&lt;BR /&gt;                "SystemItem": "Cancel",&lt;BR /&gt;                "Position": "Left",&lt;BR /&gt;                 "OnPress": "/PracticeV_1/Actions/CloseModalPage.action"&lt;BR /&gt;            }&lt;BR /&gt;        ],&lt;BR /&gt;        "_Name": "ActionBar"&lt;BR /&gt;    }
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Oct 2022 19:19:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/replacing-image-dynamically/qaq-p/12608196</guid>
      <dc:creator>former_member829117</dc:creator>
      <dc:date>2022-10-21T19:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing image dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/replacing-image-dynamically/qaa-p/12608197#M4728795</link>
      <description>&lt;P&gt;The key thing here is that you cannot directly modify the section like you are trying to do in the rule.&lt;/P&gt;&lt;P&gt;You will want to probably need use a rule for the Image property in the image section.  This rule will check if you have selected a different image or should display the default image (from the default binding which I assume would be a product detail page).&lt;/P&gt;&lt;P&gt;You logic for determining the new image path reference is fine you just need to store it in a temp location (I would suggest the page level client data) so when you redraw the image section it can get the updated path reference.&lt;/P&gt;&lt;P&gt;You can redraw just the image section using imageControl.redraw(); but keep in mind that the size of the section will not automatically adjust on redraw.  This is something we should investigate for a future enhancements.  If you want to also have the section size change you will need to redraw the whole page using pageProxy.redraw().&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 05:16:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/replacing-image-dynamically/qaa-p/12608197#M4728795</guid>
      <dc:creator>bill_froelich</dc:creator>
      <dc:date>2022-10-24T05:16:34Z</dc:date>
    </item>
  </channel>
</rss>

