Widget 2 Newtableview Question And Comment

What about creating a module variable for your tableView?

Something like:

local myTV; local onRowRender = function(event) if (event.name == "rowRender") -- use myTV to access any properties end end myTV = widget.newTableView(......, onRowRender=onRowRender);  

I need a reference, not upvalues.   My ORR function, my data rows, and my TV object are created in entirely different places and thus I can’t (and don’t want to) do this with upvalues.   Think clean OOP…

Thanks for the suggestion though.

Someone at Corona please show me how to get a reference to the final parent of the row

Dewey

To get at the TV object…what about using event.target in your ORR?

Yay Ingemar!!!—good guess, or did you find it somewhere!!  

It works in ORR, but does NOT work in onRowTouch…which is weird and inconsistent!!

Corona…please add some detailed documentation for the event records sent to these various widget functions

Great!

I use the Lua Glider IDE for my Corona development. With it I set a breakpoint inside the ORR and inspected the variables for ‘event’, and saw the ‘target’ there.

I did the same for ORT and there’s a ‘target’ there too, but for some reason it points to the same object as ‘row’.

Hi ingemar, dgaedcke,

Although you are correct about the inconsistency between ORR and ORT, you can always go like this inside ORT:

        print(event.target.parent.whateverVariable)

To access the tableview’s global properties.

Hope this helps,

Alex.

Thanks Alex—really appreciate the answer.   Will you guys be adding documentation for the event records being passed??  Also, I thought I heard v2 was also going open-source.  When will that happen?

Thx

Dewey

Already happened :slight_smile:

https://github.com/coronalabs

Alex,

“event.target.parent._data” is not working for me inside of onRowTouch (ORT)

Here is what I’m doing:

local tv = widget.newTableView(tableParams)

tv._data = data – keep ref to the data passed

inside of ORT, I try:

local rowData = event.target.parent._data[event.row.index]

and I get:

       attempt to index field ‘_data’ (a nil value)

I just downloaded the newest daily build so I know it’s not a version problem…about to dig through the source code now

ok, here is the problem:

from line 394 in widget_tableview.lua, you have:

                local newEvent =

                {

                    phase = “release”,

                    target = event.target,

                    row = self._targetRow,

                }

event.target != tableview

and the row (self._targetRow) doesn’t have any attribute pointing to it’s parent either

I can fix my version but then I void the warrantee ;-) 

feedback requested!!

Thx,
D

PS  please use a function to create the event record so it’s consistent throughout the module and does not need to be edited in 6 different places…thanks, you guys rock!