hareendra:
I read that there is a way of extending an existing form instead of creating a form from scratch.
You could use the code as shown below, just fill in the blanks.
var $smForm = solutionModel.newForm( name, server_name|data_source, [table_name], style, show_in_menu, width, height);
$smForm.extendsForm = <formname you want to extend>
hareendra:
So i basically want to add some columns i retrieve from a dataset into an existing form
This can not be done at the moment. A dataset-datasource can only be assigned with the 'solutionModel.newForm ’ function.
BUT… you can not use the extendForm function as this will mess up with your assigned dataset-datasource.
Servoy confirmed somewhere else on this forum that this will be fixed in the next release.
A workaround:
- create a form with all the ‘permanent’ fields and a tabpanel
- create a simple form using the dataset-datasource and place this on the tabpanel.
hareendra:
Or is there a way of assigning my dataset columns to the data providers of existing fields?
No, as it is impossible to assign a dataset-datasource to an existing form.
I think the code below illustrates how to start:
function createDs()
{
// create dataset with named columns
var $dataset = databaseManager.createEmptyDataSet( 5, ['my_id', 'my_name']);
// fill your dataset in some way, below is just test...
for(var i=1; i <= $dataset.getMaxRowIndex() ; i++)
{
$dataset.setValue(i,1,i);
$dataset.setValue(i,2,'name ' + i);
}
// create a datasource from your dataset. Make sure you enter a columntype for each column.
var $datasource = $dataset.createDataSource('mydata', [DM_COLUMNTYPE.INTEGER, DM_COLUMNTYPE.TEXT])
var $newForm = 'yourNewForm';
var jsform = solutionModel.newForm($newForm, $datasource, null,true, 300, 300);
jsform.view = SM_VIEW.LOCKED_TABLE_VIEW;
jsform.newField('my_id',SM_DISPLAYTYPE.TEXT_AREA,0,5,100,20);
jsform.newField('my_name',SM_DISPLAYTYPE.TEXT_AREA,70,5,100,20);
forms[$newForm].controller.show();
}