PreviewWidget of type table does not work

Bug #1543804 reported by ric silva
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
unity-js-scopes
Fix Committed
Undecided
Marcus Tomlinson

Bug Description

I'm trying to use a PreviewWidget of type 'table' but have had no success so far.

The C++ API docs say that the 'values' attribute expects an array with one element per row. Each element is supposed to be an array with two strings: label and value. So if I understand correctly I should be able to feed it something like:

var details = scopes.lib.PreviewWidget("details", "table");
details.add_attribute_value("title", "Details");
details.add_attribute_value(
    "values",
    [
        ["type", result.get("type")],
        ["channels", result.get("channels")],
        ["filesize", result.get("filesize")],
    ]
);

This does not work. It does not fail with an error, but the generated widget only displays the title, and no table rows.

Looking at the source code for preview-widget.cc, the add_attribute_value() method is only handling the cases where the contents of a passed array are dicts. With this in mind, I've tried to change my code to the following:

details.add_attribute_value(
    "values",
    {
        "type": result.get("type"),
        "channels": result.get("channels"),
        "filesize": result.get("filesize"),
    }
);

This also does not work, I get the same result (nothing is displayed in the table widget).

I guess my first attempt should have worked. The second attempt, even if it did work, would be inappropriate, because it would not be possible to use the same label on different rows of the table.

Related branches

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Yeah, your first code snippet is correct. Pushing a fix for this now.

Changed in unity-js-scopes:
assignee: nobody → Marcus Tomlinson (marcustomlinson)
status: New → In Progress
Changed in unity-js-scopes:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.