A quick way to clear the contents of an unbound table

I'm using an unbound table to accumulate a user's selections from a super long drop down list - that way the user can see all of the selections easily before he finalizes. When he clicks "OK" and I'm finished with the data, I want to clear the table to start over. I figured it would be easiest just to replace the tables entire dataset. I can't quite get it to work with scripting. Something's breaking down between the Pydataset and the dataset.

When I try this code:

tbl = event.source.parent.getComponent('tblBenefitsList') header = ['id','Benefit'] data = system.dataset.toDataSet(header) tbl.data = data

I get this error:

And when I try this code:

tbl = event.source.parent.getComponent('tblBenefitsList') header = ['id','Benefit'] row = [None, None] data = system.dataset.toDataSet(header,row) tbl.data = data

I get this error:

I feel I'm getting close using this approach, but maybe there's a better way entirely.

Disregard. Literally 15 seconds after my post, I tried this code and it worked.

tbl = event.source.parent.getComponent('tblBenefitsList') header = ['id','Benefit'] row = [] data = system.dataset.toDataSet(header,row) tbl.data = data

I’ll leave the post up in case it benefits someone else or if someone wants to show me a better way.

1 Like