Skip to content

UpdateHtmlArray - cWebHtmlBox

Updates the HTML on the client without making the psHtml a synchronized property

Type: Procedure

Parameters

Parameter Type Description
aHtml String[] Array of HTML code to update the client with

Syntax

Procedure UpdateHtmlArray String[] aHtml

Call Example

Send UpdateHtmlArray aHtml

Description

Updates the HTML on the client without making the psHtml a Web property. This improves performance because HTML is not sent back with each call.

This procedure can be used to update the HTML in the cWebHtmlBox. Instead of passing a single string, an array of strings can be passed that is concatenated on the client into a single string. One can also use the array as a string builder.

Note that in some languages using the array as a string builder is faster than concatenating strings all the time (JavaScript is such a language). Performance of this with large strings in DataFlex is unknown.

Sample

You can test this with the following code (replacing this function in the WebOrderMobile sample workspace dashboard):

Procedure RefreshRecentCustomers
    // Regenerate this panel's content.
    //
    // element structure:
    //
    // <ul>
    //    <li>
    //        <div>Customer.Name</div>
    //    </li>
    // </ul>
    String[] aHtml 
    String sRowID
    Integer iRow
    RowID riCustomer

    Move '<ul>' to aHtml[0]

    // Iterate the 7 latest Customers
    // Establish the find ordering and find the first record.
    Move 0 to iRow            
    Send Request_Read of oCustomer_DD LAST_RECORD (RefTable(Customer)) 1

    //  Find remaining records....
    While (Found and (iRow < 7))
        Move (GetRowID(RefTable(Customer))) to riCustomer
        Move (SerializeRowID(riCustomer)) to sRowID

        // Generate the <li> row element

        Move ('<li data-ServerOnClick="' + sRowID + '">') to aHtml[SizeOfArray(aHtml)]
        Move ('<div>' + htmlEncode(trim(Customer.Name)) + '</div>') to aHtml[SizeOfArray(aHtml)]
        Move ('</li>') to aHtml[SizeOfArray(aHtml)]

        Increment iRow
        Send Request_Read of oCustomer_DD LT (RefTable(Customer)) 1
    Loop

    Move ("</ul>") to aHtml[SizeOfArray(aHtml)]
    Send UpdateHtmlArray of oRecentCustomers_box aHtml
End_Procedure