cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use the value of a singleRowSelect as src for an image

Former Member
0 Kudos

Hi,

Does anybody knows how I can use the value of a SingleRowSelect as the src for an image.

I can only find exemples where they use the SingleRowSelect function to fill a textfield:

e.g.

productDetailsLayout.createRow(

new sap.ui.commons.Label({text:"Model", width:"100px"}),

               new sap.ui.commons.TextField("model",{editable:false, width:"150px", value : "{model}", required : true}),

               new sap.ui.commons.Label({text:"Description", width:"100px"}),

               new sap.ui.commons.TextField("description",{editable:false, width:"150px", value : "{description}", required : true}),

               new sap.ui.commons.Label({text:"Price", width:"100px"}),

               new sap.ui.commons.TextField("price", { editable: false, width: "200px", value: "{price}", required: true }),

               new sap.ui.commons.Label({ text: "Image", width: "100px" }),

               new sap.ui.commons.Image({src: "{detail_url}", width: "200px", height: "200px"})

);

With this code all the textfields will be filled with the selected data, but I can't show the image.

So If anyone knows what I have to change in line 9 in the code above, please tell me!

Thanks,

Robbe Wuyts

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member191810
Participant
0 Kudos

Hi.

I think the problem is in your URL, try to put in a relative path.

Former Member
0 Kudos

I don't think that's the problem. I just don't know how I can get the value of my single row select. I only know how I can use it to fill a textfield of textarea, by using it like this:

new sap.ui.commons.TextField("detail_url")

or

new sap.ui.commons.TextArea("detail_url")

former_member191810
Participant
0 Kudos

Hi.

Try with this change:

new sap.ui.commons.Image({src: "{detail_url}", width: "200px", height: "200px"})

with

new sap.ui.commons.Image({

                                                                      src : "'" + detail_url + "'"

                                                            })),

former_member191810
Participant
0 Kudos

Hi.

In the constructor of your image and without '{' nor '}':

new sap.ui.commons.Image({src : " ' " + detail_url + " ' "}))

Former Member
0 Kudos

Hey Raul,

I tried it, but it gives me an error:

0x800a1391 - Microsoft JScript runtime error: 'detail_url' is undefined

Thanks for your help and time anyways.

former_member191810
Participant
0 Kudos

Don't worry.

You must define in your JSCript file this variable and pass it with the url you want:

var detail_url = 'my url';

former_member182048
Active Contributor
0 Kudos

Hi Robbe

For me that looks like it should work. Is the URL for the "detail_url" fully qualified, ie can you put it in the address bar and find and display an image?

As an alternative you could use, which works for me.

var oImage = new sap.ui.commons.Image().bindProperty("src", "detail_url");

oImage.setHeight("200px");

oImage.setWidth("200px");

Cheers

John P

Former Member
0 Kudos

Yes, i.e. the url from the first line is:

HTTP://WWW.BEHRINGER.COM/ASSETS/B212XL_P0A0R_RIGHT_XL.PNG

Here's the code I use for my signleRowSelect:

    ProductTable.attachRowSelect(function (oEvent) {
        var currentRowContext = oEvent.getParameter("rowContext");
        var selectedUserID = oModel.getProperty("model", currentRowContext);
     
     
        OData.read("http://scvwis0046.dcsc.be:8010/sap/opu/odata/sap/Z_RFM_BEHRINGER_CM_WR/z_rfm_behringer_wrCollection('" + selectedUserID + "')",
        function (response) {
            sap.ui.getCore().getControl("model").setValue(response.model);
            sap.ui.getCore().getControl("description").setValue(response.description);
            sap.ui.getCore().getControl("price").setValue(response.price);
            sap.ui.getCore().getControl("detail_url").setValue(response.detail_url);

        });
    });

  1. var oImage = new sap.ui.commons.Image().bindProperty("src", "detail_url"); 
  2. oImage.setHeight("200px"); 
  3. oImage.setWidth("200px"); 

This code doesn't work for me.