refreshComponentForCell() of tableListModel gives wrong rowNumber


#1

Hi, I'm reading an xml into a tableList. There is one column that I want to edit directly from cell. So I use refreshComponentForCell(int rowNumber, int columnId, bool isRowSelected, Component* existingComponentToUpdate) to customize a textEditor. However, rowNumber only reaches the number of rows the tableList can show at a time, then goes back to 0 and starts again. For example, if a xml has 100 lines and the tableList can show 10 rows, the rowNumber will iterate from 0 to 9 for 10 times, not from 0 to 99 as I expect. My Juce version is 3.0.5. Any Ideas about this?


#2

Not quite sure I understand.. but am pretty sure that row number must be correct, otherwise none of my tables would show up correctly!


#3

Sorry, it was my mistake. I figured out a tableList only created a number of custom components it can show at a time and refresh/reuse them when I scroll down and up.  Thanks for clarification. It should be something like this:


Component* refreshComponentForCell(int rowNumber, int columnId, bool isRowSelected, Component* existingComponentToUpdate)
{
    if(columnId == 8)
    {
        Label* label = (Label*)existingComponentToUpdate;
        if (label == 0)
        {
            label = new Label();
        }
        label->setText(String(rowNumber), dontSendNotification);
        return label;
    }
    else
        return 0;
}