Search code examples
iostitaniumvisibletitanium-alloy

Hiding <TableViewRow> in Titanium


Ok, this is (or ought to be) straightforward - unless I am overlooking something (which probably is the case).

I have created a very simple example:

index.xml

<Alloy>
    <Window>
        <TableView>
            <TableViewSection>
                <TableViewRow>
                    <Label>Row 1</Label>
                </TableViewRow>
                <TableViewRow visible="false">
                    <Label>Row 2</Label>
                </TableViewRow>
                <TableViewRow id="row3">
                    <Label>Row 3</Label>
                </TableViewRow>
            </TableViewSection>
        </TableView>
    </Window>
</Alloy>

... and index.tss:

"#row3":{visible:false}

"Window": {
    top: 60
}

I would have expected that row 2 and row 3 were NOT displayed. However, all rows display (in the iOS Simulator).

I have read about similar issues in earlier versions of Titanium Studio. The workaround from these 2-4 years old posts were to set the height of the tableviewrow to 1 (as 0 is ignored). However, this still shows part of the label. Then I can hide the label (visible="false" workst for that!) and then I only see a "thin" row. But with the standard view row separators you still see that there is a row....

So, what am I doing wrong here??

I use the TableView layout to create a form for entering data - and some of the rows should only be shown to the user if a switch is set. Is there a better pattern for doing this?

I am on Studio 3.4.1GA, Mac OS X 10.10.1 and using the 8.1 iOS in simulator ;-)

Thank you in advance!

/John


Solution

  • I also asked this question in the developers' Q&A on appcelerator.com. I ended up getting a couple of suggestions as to how to solve it - both using the Alloy markup. The best solution is along the lines of what Lucky Luke suggests - but using Alloy instead of creating the TableView using the traditional coding style.

    Here is a link to the solution I chose.

    Sorry that I hadn't come around and added the link here before now.

    /John