Problem with DesktopHTMLViewer loading from source as string

Hi all,
i have this HTML code that uses Tablutor Javascript library, Im trying to display it in a DesktopHTMLViewer, when i use LoadPage(filepath) and i pass the HTML file path it works well, but when i copy the HTML code in a variable and i try to load it using LoadPage(varName) it doesnt work , i believe the problem is with the library path but cant seem to figure it out.
ps : i tried changing the library path to absolute path it doesnt work!
i have tabulator.min.css and tabulator.min.js in the project folder

Thank you
this is my HTML code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="tabulator.min.css">
    <script src="tabulator.min.js"></script>
</head>
<body>
    <div id="example-table"></div>
    <script>
var tableData = [{ id: 1, name: 'Oli Bob', progress: 12, gender: 'male', rating: 1, col: 'red', dob: '14/04/1984' },{ id: 2, name: 'Mary May', progress: 1, gender: 'female', rating: 2, col: 'blue', dob: '14/05/1982' },]
var table = new Tabulator("#example-table", {
            height: "311px",
            resizableRows: true, // Enable resizable rows
            frozenRows: 2,
            data: tableData,
            columns: [
                { title: "Name", field: "name" , frozen: true},
                { title: "Progress", field: "progress", sorter: "number" , frozen: true},
                { title: "Gender", field: "gender" },
                { title: "Rating", field: "rating" },
                { title: "Favourite Color", field: "col" },
                { title: "Date Of Birth", field: "dob", hozAlign: "center" },
            ],
        });
    </script>
 </body>
</html>

In a build step move your html support files to a proper resource folder

At runtime create a FolderItem (let’s call it “fiTabulator”) pointing to where " tabulator.min.js" file will be

Then use it as

html.LoadPage(myHTMLasString, fiTabulator)

Thank you @Rick_Araujo for your reply, unfortunately it did not work

Maybe we need some help here.

Looks like HtmlViewer.LoadPage( HTML_String, FolderItem_FileInBaseDir ) is broken ?

The HTML code loads, but seems that the includes there don’t.

I moved away from having the html in a string and loading that, because:

  1. It didn’t work on Windows (or was it Linux? I forget which now but can probably look it up).

  2. One had to use a Declare to be allowed to load images.

  3. Internal links within the page, so the reader can click the link and the page scrolls there, didn’t work.

So these days I just always write it to a file and then load that.

If all this is precisely correct. HtmlViewer.LoadPage( HTML_String, FolderItem_FileInBaseDir ) is basically useless unless you just want to show some text and tabular data statically rendered, nothing at runtime depending of includes of js libs and etc.

thank you @TimStreater for you reply, im developing for windows , according to the documentation LoadPage(page As FolderItem) This method signature is not supported on Windows due to CEF Security.
thats why i choose the LoadPage(source As String, base As FolderItem) instead

actually what am trying to do is to render tabular data with freeze panes and resize row , column capability, because cant find any reliable xojo grid component or plugin … :frowning:

The method signature LoadPage (page As FolderItem) works for me under Win-10. The html file is in the same folder as the images to be loaded, so the html contains such as:

<img src=“myimage.png”>

For fun, here is a workaround just for this case:

https://www.transfernow.net/dl/20240229qqyxo8K0

Not tested on a Mac

All self contained and resolving in memory because this lib (tabulator.js) allows us doing it.

2 Likes

Thank you so much @Rick_Araujo
You are a life saver!! :smile:

1 Like