Italian altezza riga in dbUtils

uniplan

Active Member
Licensed User
Longtime User
Salve,
ho utilizzato il modulo dbUtils per visualizzare in una table i risultati di una query.

usando:

B4X:
WebView1.LoadHtml(DBUtils.ExecuteHtml(Main.SQL1, txt, Array As String(attivo_loc,codice_loc,descrizione_loc),0, True))

tutto funziona correttamente. Vorrei però aumentare un po' il font dei caratteri e l'altezza della riga.

Ho visto che in dbUtils c'è un foglio di stile:

B4X:
   HtmlCSS = "table {width: 100%;border: 1px solid #cef;text-align: left; }" _
      & " th { font-weight: bold;   background-color: #acf;   border-bottom: 1px solid #cef; }" _ 
      & "td,th {   padding: 4px 5px; }" _
      & ".odd {background-color: #def; } .odd td {border-bottom: 1px solid #cef; }" _
      & "a { text-decoration:none; color: #000;}"

Qualcuno sa come modificarlo per ottenere i risultati di cui vi parlavo?

Grazie.
 

arenaluigi

Well-Known Member
Licensed User
Longtime User
Non ho mai utilizzato questa classe, ma devi verificare quale css chiama e quale id o classe del css usa, poi individuata questa, si dovrebbe modificare la proprietà height.

Inviato dal mio GT-I9300 con Tapatalk 2
 

klaus

Expert
Licensed User
Longtime User
Here you have a modified version of the ExecuteHtml routine that allows to set the TextSize as a parameter.
B4X:
'Creates a html text that displays the data in a table.
'The style of the table can be changed by modifying HtmlCSS variable.
'The TextSize parameter allows to change the text size, standard is 16
Sub ExecuteHtml2(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Clickable As Boolean, TextSize As Int) As String
    Dim Table As List
    Dim cur As Cursor
    Dim HtmlCSS2 As String
    
    HtmlCSS2 = "table {width: 100%;border: 1px solid #cef;text-align: left; }" _
    & " th { font-size:" & TextSize & "px; font-weight: bold;    background-color: #acf;    border-bottom: 1px solid #cef; }" _ 
    & "td,th {    padding: 4px 5px; }" _
    & ".odd {background-color: #def; } .odd td {border-bottom: 1px solid #cef; }" _
    & "a { font-size:" & TextSize & "px; text-decoration:none; color: #000;}"

    If StringArgs <> Null Then 
        cur = SQL.ExecQuery2(Query, StringArgs)
    Else
        cur = SQL.ExecQuery(Query)
    End If
    Log("ExecuteHtml: " & Query)
    If Limit > 0 Then Limit = Min(Limit, cur.RowCount) Else Limit = cur.RowCount
    Dim sb As StringBuilder
    sb.Initialize
    sb.Append("<html><body>").Append(CRLF)
    sb.Append("<style type='text/css'>").Append(HtmlCSS2).Append("</style>").Append(CRLF)
    sb.Append("<table><tr>").Append(CRLF)
    For i = 0 To cur.ColumnCount - 1
        sb.Append("<th>").Append(cur.GetColumnName(i)).Append("</th>")
    Next
    
    sb.Append("</tr>").Append(CRLF)
    For row = 0 To Limit - 1
        cur.Position = row
        If row Mod 2 = 0 Then
            sb.Append("<tr>")
        Else
            sb.Append("<tr class='odd'>")
        End If
        For i = 0 To cur.ColumnCount - 1
            sb.Append("<td>")
            If Clickable Then
                sb.Append("<a href='http://").Append(i).Append(".")
                sb.Append(row)
                sb.Append(".com'>").Append(cur.GetString2(i)).Append("</a>")
            Else
                sb.Append(cur.GetString2(i))
            End If
            sb.Append("</td>")
        Next
        sb.Append("</tr>").Append(CRLF)
    Next
    cur.Close
    sb.Append("</table></body></html>")
    Return sb.ToString
End Sub
Best regards.
 

uniplan

Active Member
Licensed User
Longtime User
Here you have a modified version of the ExecuteHtml routine that allows to set the TextSize as a parameter.
B4X:
'Creates a html text that displays the data in a table.
'The style of the table can be changed by modifying HtmlCSS variable.
'The TextSize parameter allows to change the text size, standard is 16
Sub ExecuteHtml2(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Clickable As Boolean, TextSize As Int) As String
    Dim Table As List
    Dim cur As Cursor
    Dim HtmlCSS2 As String
    
    HtmlCSS2 = "table {width: 100%;border: 1px solid #cef;text-align: left; }" _
    & " th { font-size:" & TextSize & "px; font-weight: bold;    background-color: #acf;    border-bottom: 1px solid #cef; }" _ 
    & "td,th {    padding: 4px 5px; }" _
    & ".odd {background-color: #def; } .odd td {border-bottom: 1px solid #cef; }" _
    & "a { font-size:" & TextSize & "px; text-decoration:none; color: #000;}"

    If StringArgs <> Null Then 
        cur = SQL.ExecQuery2(Query, StringArgs)
    Else
        cur = SQL.ExecQuery(Query)
    End If
    Log("ExecuteHtml: " & Query)
    If Limit > 0 Then Limit = Min(Limit, cur.RowCount) Else Limit = cur.RowCount
    Dim sb As StringBuilder
    sb.Initialize
    sb.Append("<html><body>").Append(CRLF)
    sb.Append("<style type='text/css'>").Append(HtmlCSS2).Append("</style>").Append(CRLF)
    sb.Append("<table><tr>").Append(CRLF)
    For i = 0 To cur.ColumnCount - 1
        sb.Append("<th>").Append(cur.GetColumnName(i)).Append("</th>")
    Next
    
    sb.Append("</tr>").Append(CRLF)
    For row = 0 To Limit - 1
        cur.Position = row
        If row Mod 2 = 0 Then
            sb.Append("<tr>")
        Else
            sb.Append("<tr class='odd'>")
        End If
        For i = 0 To cur.ColumnCount - 1
            sb.Append("<td>")
            If Clickable Then
                sb.Append("<a href='http://").Append(i).Append(".")
                sb.Append(row)
                sb.Append(".com'>").Append(cur.GetString2(i)).Append("</a>")
            Else
                sb.Append(cur.GetString2(i))
            End If
            sb.Append("</td>")
        Next
        sb.Append("</tr>").Append(CRLF)
    Next
    cur.Close
    sb.Append("</table></body></html>")
    Return sb.ToString
End Sub
Best regards.

Hi Klaus,
I have used your modified version of the ExecuteHtml.
It work, but sometime not all records returned by the query are displayed in the grid.
Have you an idea of ​​why this happens?
Thanks.
 

klaus

Expert
Licensed User
Longtime User
How do you call ?
B4X:
Sub ExecuteHtml2(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Clickable As Boolean, TextSize As Int) As String
What value has the Limit parameter ?
If Limit > 0 and Limit < Cursor.RowCount then not all rows will be shown.
This is the same as with the original Sub ExecuteHtml routine.
This is limited in this line:
B4X:
If Limit > 0 Then Limit = Min(Limit, cur.RowCount) Else Limit = cur.RowCount
Best regards.
 

uniplan

Active Member
Licensed User
Longtime User
Hi Klaus,

I call ExecuteHtml2 with limit = 0.

I have verified and ExecuteHtml2 returns all records.
However WebView1 display only a part of rows and does not allow the scroll.

Thanks.

Antonio.
 
Top