TableView render different kinds of rows

Hi, this seems like a pretty obvious thing but I can’t seem to figure out how to do it. Perhaps it’s the recent lack of sleep but I’ve been struggling with it for a few hours now to no avail.

How can you render two different rows in the same tableView using the new 2.0 widgets? The way it works as I see it is that you assign  one  row render listener to the tableView, and this will be called each time a row is rendered? But how can you have the tableView render different types of rows depending on something dynamic?

Previously, I had a for loop that iterated through a table and would create an onRender function for each iteration and then insert that into the tableView. Since you specified the onRender listener inside the :insertRow method, you could create whatever type of row render you wanted on the fly. Now we can only use one “global” listener for all rows, so how can you alter this listener to render different types of rows?

I tried using the event.index variable inside the listener to try determine what row should be where, but things wont be this static all the time. Sometimes I’ll be fetching different kind of data from my server and it wont always be organized the same way.

Sorry if it sounds messy, blaming it on lack of sleep :slight_smile: Basically, I think it could be fixed by somehow being able to pass custom variables to the onRowRender listener, but is this even possible somehow?

Heh, ugh after writing this long confusing post I realized you could pass an “id” parameter to the onRowRender function which will help solve the issue. :slight_smile:

Hi @Mitaten,

Yes, you’re correct, that’s one method. Otherwise, it’s not yet possible to pass custom variables/parameters to the onRowRender() function directly from the “:insertRow()” call.

However, I know that some people would find this ability useful, so I’ve sent a feature request to the engineering team. Most likely, the solution will feature the ability to pass a table called “params” from the insert row API, like this:

[lua]

myTableView:insertRow{

   isCategory = false,

   rowHeight = 44,

   rowColor = { default={150,0,0}, over={255,0,0} },

   params = { myParam1=“foo”, myParam2=“foo2” }

}

[/lua]

Then later, you could access those params like this:

[lua]

event.row.params.myParam1

[/lua]

Hopefully that would provide another convenience method for TableView. When I get the report/case number, I’ll post it here so you can track it.

Best regards,

Brent

Heh, ugh after writing this long confusing post I realized you could pass an “id” parameter to the onRowRender function which will help solve the issue. :slight_smile:

Hi @Mitaten,

Yes, you’re correct, that’s one method. Otherwise, it’s not yet possible to pass custom variables/parameters to the onRowRender() function directly from the “:insertRow()” call.

However, I know that some people would find this ability useful, so I’ve sent a feature request to the engineering team. Most likely, the solution will feature the ability to pass a table called “params” from the insert row API, like this:

[lua]

myTableView:insertRow{

   isCategory = false,

   rowHeight = 44,

   rowColor = { default={150,0,0}, over={255,0,0} },

   params = { myParam1=“foo”, myParam2=“foo2” }

}

[/lua]

Then later, you could access those params like this:

[lua]

event.row.params.myParam1

[/lua]

Hopefully that would provide another convenience method for TableView. When I get the report/case number, I’ll post it here so you can track it.

Best regards,

Brent