Hi,
I am using the solution model to create a form. Besides the query, I need an additional column so I did;
_Dataset.addColumn(‘new_column’,_maxColumnIndex+1);
Then when creating the data source, I added an extra column to the column type array like;
_Dataset.createDataSource(‘newData’,[DM_COLUMNTYPE.TEXT,DM_COLUMNTYPE.TEXT,DM_COLUMNTYPE.TEXT])
I specifically gave the new column type as DM_COLUMNTYPE.TEXT, because I wanted it as a text type column.
However, when I try to assign values to the new_column, I am only allowed to assign integer type values. I get the error;
Setting dataprovider with name ‘new_column’, type ‘INTEGER’ with value of wrong type X
java.lang.IllegalArgumentException: Setting dataprovider with name ‘new_column’, type ‘INTEGER’ with value of wrong type X
Does anyone have an idea?
Regards,
Hareendra
Hi Hareendra,
if you look at the signature for the JSDataSet.addColumn() method, you can see that there are 2 “optional” parameters (between square brackets ):
_Dataset.addColumn(column_name,[column_index],[column_type]);
So I suspect that when you are using:
_Dataset.addColumn(‘new_column’,_maxColumnIndex+1);
Servoy took the _maxColumnIndex+1 as an Integer or misunderstood it correctly in some ways.
You should also remember that the [column_index] is zero-based, - it ranges between 0 and n-1 (n = number of columns)-, so it might be that what you really need to write (depending on how you calculate your maxColumnIndex var) is in fact:
_Dataset.addColumn(‘new_column’,_maxColumnIndex);
To make it easy I would either use:
_Dataset.addColumn(‘new_column’);
or (to make it plain):
_Dataset.addColumn(‘new_column’,_maxColumnIndex,DM_COLUMNTYPE.TEXT);
There is also the fact that you say you first add a column and then you create a datasource, shouldn’t it be the other way round?
Hope this helps,
Patrick