Hi,
I have an app showing a list of audio tracks into a WebListBox, the List is loaded from database using a dataSource.
All is working fine, and I have been able also to draw a Picture in a cell with the album cover.
I have done it this way, the code is in the RowData method of the dataSource:
Var stcop As new WebStyle
stcop.Value(“background-image”) = “url(”“”+session.pathCopertine + rs.Column(“ca_logo”).StringValue+“”“)”
stcop.Value(“background-repeat”) = “no-repeat”
stcop.Value(“background-position”) = “center”
rendcop = new WebListBoxStyleRenderer(stcop,“”)
row.Value(“immCopertina”) = rendcop
All works fine, except that when a row is selected, the select color ‘covers’ the picture…
so two questions:
-
if the WebListBox has a dataSource, is it possible to store somewere the cover path, or I must necessarily do a query using the track id stored on the row Tag every time a track is selected to retrieve it?
-
Having in some way the cover path, how can I redraw the cell on the SelectionChanged event?
Thank you!
I have posted much simpler question pertaining to WebListbox with DataSource, I want to change background color of the cell, so far no luck.
However, I think you could store the cover path in the Tag of the row inside RowData method.
I store primary and foreign keys as comma separated list in the Tag, then I can access them when selecting row (read the tag string and parse it). I think you could do the same for the cover path. This is how RowData looks:
Var rows() As WebListboxRowData
If mQuery.Length = 0 Or mQueryCount = 0 Then
Return rows
End If
mLastSortColumnStr = pSortColumnStr
mLastRowOffset = rowOffset // 2024.07.31 <gp> added
Try
Var vPos As Integer
Var sql As String
sql = mQuery
vPos = sql.IndexOf("ORDER BY")
If vPos > 0 Then
sql = sql.Middle(0,vPos)
End If
If pSortColumnStr.Length > 0 Then
//sql = sql + " ORDER BY " + pSortColumnStr
sql = sql + " ORDER BY " + pSortColumnStr + ", id asc"
Else
sql = sql + " ORDER BY id asc"
End If
sql = sql + " LIMIT " + Str(RowCount) + " OFFSET " + Str(RowOffset)
Var rs As RowSet
If mParamArray.LastIndex = -1 Then
rs = Session.db.SelectSQL(sql)
ElseIf mParamArray.LastIndex = 0 Then
rs = Session.db.SelectSQL(sql,mParamArray(0))
ElseIf mParamArray.LastIndex = 1 Then
rs = Session.db.SelectSQL(sql,mParamArray(0),mParamArray(1))
ElseIf mParamArray.LastIndex = 2 Then
rs = Session.db.SelectSQL(sql,mParamArray(0),mParamArray(1),mParamArray(2))
ElseIf mParamArray.LastIndex = 3 Then
rs = Session.db.SelectSQL(sql,mParamArray(0),mParamArray(1),mParamArray(2),mParamArray(3))
End If
Var vColumnDataStr As String
Var vColumnDataStrArray() As String
Var vFldName As String
Var i As Integer
Var vMyTag As String
rs.MoveToFirstRow // 2024.07.31 <gp> added
While Not rs.AfterLastRow
Var row As New WebListBoxRowData
vMyTag = ""
For i = 0 To mColumnDataArray.LastIndex
vColumnDataStr = mColumnDataArray(i)
vColumnDataStrArray = vColumnDataStr.ToArray(",")
vFldName = vColumnDataStrArray(1)
If vColumnDataStrArray(0) = "pk" Then
row.PrimaryKey = rs.Column(vFldName).StringValue.ToInteger
ElseIf vColumnDataStrArray(0) = "tag" Then
// may use it for something but do not show on page
Var vValue As String
vValue = rs.Column(vFldName)
If vMyTag.Length = 0 Then
vMyTag = vValue
Else
vMyTag = vMyTag + "," + vValue
End If
Else
Var vValue As String
vValue = rs.Column(vFldName)
row.Value(vFldName) = vValue
//row.Value(vFldName) = rs.Column(vFldName).StringValue
End If
Next
row.Tag = vMyTag
rows.Add(row)
rs.MoveToNextRow
Wend
rs.Close
Return rows
Catch ex As DatabaseException
Break
End Try
Return rows