TableListBox with ValueTrees

Question: ValueTrees are incredibly useful, and cover functionally what XmlElements offer (but add to that!). The Juce TableListBox uses XmlElements (for both header and data) - is there a ValueTree version of the TableListBox component? If not, any reason why not?

I’m working on a series of plugins in which I store big amounts of dynamic data, which are shown in TableListBoxes. I store the data in Xml and that works great. But having the data in ValueTree object would save me a lot of manual coding that I now need to do to keep the UI up to date when data changes … that’s functionality ValueTrees adds on top of the functional equivalent of Xml … but since I need the TableListBox model I’m stuck with Xml it seems. Or am i?

Thoughts or opinions?

I don’t see any mention of Xml in TableListBox or TableListBoxModel…? Are you using subclasses of those from some Juce example code or something?

1 Like

The TableListBox uses XmlElements internally to store the data. You can see that e.g. by looking at the tutorial: the data is stored as follows:

std::unique_ptr<XmlElement> tutorialData; 
XmlElement* columnList = nullptr;
XmlElement* dataList = nullptr;

That seems to indicate that both the header is an XML list, and the data is a list of lists. Am I wrong? If I look at how these things are being populated in the tutorial that also points to XmlElements as internal datamodel.

class TableTutorialComponent    : public Component,
                                  public TableListBoxModel
{
//...
private:
    //...
    std::unique_ptr<XmlElement> tutorialData;
    XmlElement* columnList = nullptr;
    XmlElement* dataList = nullptr;
    //...
};

that’s a TableListBoxModel, not a TableListBox

1 Like

Ah! Could it be that the tutorial just happens to store the data in Xml? I’m kinda busy right now but if that is the case I could easily refactor the tutorial example to a version that uses ValueTrees instead of Xml! Thx - you’ve given me some inspiration!

Yup - did a quick check: getText() and setText() in the tutorial code copy the data from Xml to table datastructure and vice versa. Should be peanuts to convert to ValueTrees !!!