Creating and adding to a dataset

I’m trying to create a dataset of a user’s roles on startup and pass them to a window for display in a list.

I’ve tried the following codedata = [] for role in data = fpmi.dataset.addRow(data,[role]) fpmi.nav.openWindow("Window 1",{'roles' : data}) but I get an error in the addRow line that the 1st arg can’t be coerced to a DataSet. I’m obviously not initialising the dataset variable correctly…


I don’t think you can add a row directly to a dataset.

I think you would have to create a roles list and a headers list and use the fpmi.dataset.toDataSet(#2) method to convert them to a dataset.

See the example in the manual.

Try this:

roles = [[role] for role in] headers = ["role"] data = fpmi.dataset.toDataSet(headers, roles)[/Edit]

Hi MickeyBob,

Thanks for the tip. I managed to get it working with the following code:headers = ["Role"] data = [] for role in data.append([role]) myDataset= fpmi.dataset.toDataSet(headers, data) fpmi.nav.openWindow("Window 1",{'roles' : myDataset})
I like the ‘3 lines for the price of 1’ Python in your code! Very compact.

I had a further problem displaying the dataset in a list. If I created an empty dataset dynamic property and tried to bind it to a dropdown list, it would bring up the following error:Error setting dropdown data for dropdown 'drpRoles':Illegal dropdown dataset: no columns. This is displayed at runtime even when the dataset being passed in contains data.

The only way I found round this problem was to create a dummy column in the dataset dynamic variable. This is replaced at runtime by the data being passed in without bringing up an error.


I couldn’t replicate your problem in the runtime, just in the development mode, and only then before I “initialized” the list with an empty dataset. Try opening the dataset editor from the properties window and adding a single column. You don’t have to add any rows to the dataset.

Attached is a quick window I put together.
RolesDemo.fwin (7.27 KB)

Thanks MickeyBob, this is like the solution I came up with. I did get the error in the runtime as well - I was running it as an applet, in case that makes any difference.