TableListBox problem

Hi,

I'm trying to use a table in my app and cannot make it work.

I'm declaring this way:

TableListBox table;


addAndMakeVisible(table);
table.setModel(this);
table.setColour(ListBox::outlineColourId, Colours::grey);
table.setOutlineThickness(1);
table.getHeader().addColumn("Qty", 1, 3, 3, 10, TableHeaderComponent::defaultFlags);
table.getHeader().addColumn("Description", 2, 30, 30, 100, TableHeaderComponent::defaultFlags);
table.getHeader().addColumn("Total", 3, 8, 8, 12, TableHeaderComponent::defaultFlags);
table.getHeader().setSortColumnId(1, false);

table.getHeader().setStretchToFitActive(true);
table.setMultipleSelectionEnabled(false);

but it stops giving me a problem with upperLimit.

Can anyone explain me why this is happening and give me one example on how to work with tables and insert data on them ?

Thanks,

Paulo

Seems that i have to set the variable numRows to zero.

 

How can i add rows to this table ?

You set it in TableListBoxModel::getNumRows()

http://www.juce.com/api/classTableListBoxModel.html#ae7ff7c6523e8113ff1c13b39f7144bf2

It's pure so you must be overriding it already. Just return the number of rows you want. 

Hi Rory,

 

yes, already overriding getNumRows, but honestly, cannot understand the method to add the row data on my table.

 

Basicly, i have 3 columns and i want to be able to addRow("Column1 data", "Column2 data", "Column3 data") to my table.

And also be able to update a row and/or delete it.

I've not used this class much but as far as I remember, you set the number of rows you want, then you call update content. That will in turn call refreshComponentForRow() on each cell. You override that method to do the drawing for each row. I think there is an examples in the Juce Demo that might help. 

Hi Rory,

I've made some progress to understand the concept and how to use it.

Now my only trouble is on how can i make a 2D array.

I know that i can create one 2D array simply doing String myArray[10][10], but i do not want to limit the size of my array, since i need less or more data.

How can I use a OwnedArray to be 2 dimensions and how to use it ?

I need to create one array that can be used like this:

my2DArray[0][1] = "something";

my2DArray[0][2] = "something";

my2DArray[0][3] = "something";

...

my2DArray[n][3] = "something";

 

And also how to know the size of my array.

And finally, when i update or add anything to my arry, i cannot find the way to refresh the table.

Thanks

 

To refresh the table just updateContent(). Have you tried looking at the StringArray class? It's simple to add a remove strings from it, as well as query its size.