Showing form using dataset

Hi,

In Servoy 5.2 there is the functionality to show forms using a dataset. I tried this, but my records are not shown. I have no idea why not.
I do see the tableview header, so the field is really on the form.

I create a form and data-source like described on the wiki pages:

	var _query_download = 'SELECT interface_session_nr FROM interface_session'
	var _ds_download = databaseManager.getDataSetByQuery('globis_development', _query_download, null, -1)

	var _data_source = _ds_download.createDataSource('interface_session_downloads'); 
		
	var _form_download = solutionModel.newForm( 'IM_downloads_ds', _data_source,  null,  'globis_tableview',  false,  300,  300)
	
	var _field = _form_download.newField('interface_session_nr', JSField.TEXT_FIELD, 20, 0, 100, 20)

	_form_download.view = JSForm.LOCKED_TABLE_VIEW
	_form_download.navigator = SM_DEFAULTS.NONE
	_form_download.scrollbars = SM_SCROLLBAR.HORIZONTAL_SCROLLBAR_NEVER | SM_SCROLLBAR.VERTICAL_SCROLLBAR_AS_NEEDED
	
	_field.editable = false;
	_field.text = 'Session nr'
	_field.anchors = SM_ANCHOR.WEST | SM_ANCHOR.NORTH | SM_ANCHOR.EAST

I added also the line:

forms.IM_downloads_ds.controller.loadAllRecords()

but that has also no effect.

When I replace the line

var _form_download = solutionModel.newForm( 'IM_downloads_ds', _data_source, null, 'globis_tableview', false, 300, 300)

with

var _form_download = solutionModel.newForm( 'IM_downloads_ds', 'globis_development', 'interface_session', 'globis_tableview', false, 300, 300)

then a correct tableview is shown. So the solutionModel scripting seems to be right.

Am I missing something here?

When creating the datasource, you didn’t specify the column types. Try this:

var _data_source = _ds_download.createDataSource('interface_session_downloads',[JSColumn.TEXT]);

Thanks Joas,

I’ll try that, but in that case maybe you have to change your wiki pages:

http://wiki.servoy.com/display/public/DOCS/JSDataSet#JSDataSet-createDataSource

because this is what is shown in the sample:

 var query = 'select customerid, address, city, country  from customers';
 var ds2 = databaseManager.getDataSetByQuery('example_data', query, null, 999);
 var uri2 = ds2.createDataSource('mydata2'); //types are inferred from query result

So I didn’t expect that those column types could be the problem (see the comment “types are inferred from query result”)

Joas,

I have found the problem. It seems to be a bug in Servoy. I created case 346577.

I showed the following code:

   var _query_download = 'SELECT interface_session_nr FROM interface_session'
   var _ds_download = databaseManager.getDataSetByQuery('globis_development', _query_download, null, -1)
   var _data_source = _ds_download.createDataSource('interface_session_downloads');      
   var _form_download = solutionModel.newForm( 'IM_downloads_ds', _data_source,  null,  'globis_tableview',  false,  300,  300)

Well in the case the second argument (_data_source) in the solutionModel.newForm() is not accepted. When you debug, then you can see that the dataSource property remains null
When I add the following line:

_form_download.dataSource = _data_source

then it works like expected. So it was not a problem of adding the [JSColumn.TEXT].

Martin

this is not a bug you are calling the newForm wrong:

this:

solutionModel.newForm( ‘IM_downloads_ds’, _data_source, null, ‘globis_tableview’, false, 300, 300)

is the way when you have a servername,tablename if you just have a datasource then the tablename shouldn’t be specified. (and this mean really not be set/given)

solutionModel.newForm( ‘IM_downloads_ds’, _data_source, ‘globis_tableview’, false, 300, 300)

i updated the sample and doc a bit to make this more clear.

In 6 code completion will give you different functions so you really get a few different functions that you can complete.