cancel
Showing results for 
Search instead for 
Did you mean: 

Images in Table cell

Former Member
0 Kudos

HI,

I have to display different images in a SAP .Net tabe control cell depends on the field values from a database. I set the Tabel cell editor property to "Image Instance" and programatically assign the relative path of the image "web resourcesimagesxxx.gif" according to the database field values. I can see at runtime the web source have correct URL to the image source but the image is not getting displayed on the iView. What am I doing wrong?? I follow this article to do the code part

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/nw/dotnet/pdk for .net faq - .net controls.faq

Please help.

thanks

Accepted Solutions (0)

Answers (5)

Answers (5)

igor_vernelen3
Active Participant
0 Kudos

Hi,

I had the same problem. At the end I found that in the <b>images</b> part of the path to the image the "i" didn't have to be in capitals. So

New SAP.Web.UI.Controls.Image("Web Resources/<b>i</b>mages/icon_green.jpg")

works fine while

New SAP.Web.UI.Controls.Image("Web Resources/<b>I</b>mages/icon_green.jpg")

doesn't work.

Regards,

Igor.

Former Member
0 Kudos

Thanks guys,

Since we're apporaching our certification deadline. I habe to look for another means and I completely chnage the design. I used a dataset component and did the scripting in the "tablecell content" source property and it is workign fine now. Thanks for all your help

Former Member
0 Kudos

Thanks for the reply guys,

Here is the code; I'm not using server "itemDtaBound"

I set the field type as "image instance" at design time and at runtime after reading the data assign the graphics to the control according to the value returned from the database at the Page_Load

I only took the relevant portion

Dim sOrderByField As String = ""

Dim sqlDate As String = FormatDBDateTimeSQL(Format(Now, "MM/dd/yyyy 00:00:00"))

'Dim ConnStr As String = "server='(local)'; trusted_connection=true; database='tllink'"

sSQL = "SELECT EmployeeName, BadgeId, Punch_Type,Punch_Date, Punch_time, TerminalID FROM TERMINAL_TRANSACTIONS"

sSQL &= " WHERE (Punch_Date =" & sqlDate & ") AND (Punch_Type IN ('IN', 'OUT' ,'DEPT' )) AND ((CAST(Punch_Time AS VARCHAR) + '-' + BadgeId) IN"

sSQL &= " (SELECT (CAST(MAX(PUNCH_TIME) AS VARCHAR) + '-' + BADGEID) FROM TERMINAL_TRANSACTIONS"

sSQL &= " WHERE (Punch_Date =" & sqlDate & ") GROUP BY BADGEID))"

rRec = g_cDB.GetRec(sSQL, , True)

OleDbDataAdapter1.Fill(dSQLSet,rRec, "TERMINAL_TRANSACTIONS")

'SQLTable = dSQLSet.Tables(0)

Dim RowCurrent As DataRow

Dim tr As SAP.Web.UI.Controls.TableRow

For Each RowCurrent In dSQLSet.Table("TERMINAL_TRANSACTIONS").Rows

tr = New SAP.Web.UI.Controls.TableRow

If IsDBNull(RowCurrent("EmployeeName")) = False Then

tr.Cells.Add(New SAP.Web.UI.Controls.TableCell(New TextView(RowCurrent("EmployeeName"))))

Else

tr.Cells.Add(New SAP.Web.UI.Controls.TableCell)

End If

If IsDBNull(RowCurrent("badgeid")) = False Then

tr.Cells.Add(New SAP.Web.UI.Controls.TableCell(New TextView(RowCurrent("badgeid"))))

Else

tr.Cells.Add(New SAP.Web.UI.Controls.TableCell)

End If

If IsDBNull(RowCurrent("Punch_Type")) = False Then

If RowCurrent("Punch_Type") = "IN" Then

tr.Cells.Add(New SAP.Web.UI.Controls.TableCell(New SAP.Web.UI.Controls.Image("Web Resources/Images/in.gif")))

ElseIf RowCurrent("Punch_Type") = "OUT" Then

tr.Cells.Add(New SAP.Web.UI.Controls.TableCell(New SAP.Web.UI.Controls.Image("Web Resources/Images/out.gif")))

Else

tr.Cells.Add(New SAP.Web.UI.Controls.TableCell(New SAP.Web.UI.Controls.Image("Web Resources/Images/transfer.gif")))

End If

End If

Me.DataTable.Items.Add(tr)

Next

My table displays the employee name and badge id but the images are coming as broken link. I added the images to the web resources before deploying the par.

The follwing is the runtime source from the browser

</td></tr><tr rr="1"><td tableid="tae241ba0_DataTable" cc="0" rr="1" class="urSTTD urSTTDBdr1" style="padding:0;"><div tabindex="0" ti="0"><span ct="TextView" style="margin:0px;"></span></div></td><td tableid="tae241ba0_DataTable" cc="1" rr="1" class="urSTTD urSTTDBdr" style="padding:0;"><div tabindex="0" ti="0"><span ct="TextView" onkeydown="sapUrMapi_TextView_menuActivate('',event)" class="urTxtStd" style="white-space:nowrap;">000000000003412770</span></div></td><td tableid="tae241ba0_DataTable" cc="2" rr="1" class="urSTTD urSTTDBdr" style="padding:0;"><div tabindex="0" ti="0"><img class="urImg" src="/irj/portalapps/Timelink_Portal_APP/Images/green.gif" ct="Image" border="0" style="height:28;width:30;"></img></div></td><td tableid="tae241ba0_DataTable" cc="3" rr="1" class="urSTTD urSTTDBdr" style="padding:0;"><div tabindex="0" ti="0"><img class="urImg" src="/irj/portalapps/Timelink_Portal_APP/Images/in.gif" ct="Image" border="0"></img></div></td><td tableid="tae241ba0_DataTable" cc="4" rr="1" class="urSTTD urSTTDBdr" style="padding:0;"><div tabindex="0" ti="0"><span ct="TextView" onkeydown="sapUrMapi_TextView_menuActivate('',event)" class="urTxtStd" style="white-space:nowrap;">2/10/2006</span></div></td><td tableid="tae241ba0_DataTable" cc="5" rr="1" class="urSTTD urSTTDBdr" style="padding:0;"><div tabindex="0" ti="0"><span ct="TextView" onkeydown="sapUrMapi_TextView_menuActivate('',event)" class="urTxtStd" style="white-space:nowrap;">07:24:58</span></div>

as you can see it includes the path to th images green.gif and in.gif

thanks

Former Member
0 Kudos

Hi again Bernhard,

I understand -

1. you have a folder called "Images" under "Web Resources".

2. in it you have the image "green.gif"

3. Your par (application) is called "Timelink_Portal_APP" (please verify this in the SAP project properties).

So far so good?

Now please try the following (after deploying this par):

open a portal in a browser, authenticate, and change the url to- "http://yourportal:portalport/irj/portalapps/Timelink_Portal_APP/Images/green.gif"

Do you see your image?

If not (and you answered "yes" to what I described before, it means somehow your image wasn't deployed. To see this, please create a par file with "create par" operation (this par should be created with the name Timelink_Portal_APP, or you misconfigured something) and then open it (with WinZip or the like) and check to see that you image is in there. let me know how all this turns out...

Regards,

Ofer

Former Member
0 Kudos

Hi Bernhard,

Can you also paste the "web source" where you say see that the correct URL is rendered?

Also (silly question, just to make sure) - Are you sure you added the images to the "web resources" folder?

Regards,

Ofer

Former Member
0 Kudos

Hi Bernhard,

Just to be sure, are u using the ItemDataBound server side event of the table?

I couldn't exactly understand from your post how u implemented it, but the ItemDataBound event should be the right place for that.

Can u please paste the code u used to set the url to the image?

Thanks, Reshef