I am trying to create a few elements in a loop, using the solution model. However I'm having a lot of difficulty naming the elements. Please see my code below.
- Code: Select all
var jsform = solutionModel.newForm(stmpForm, _dataSource, null, true, 510, 300);
jsform.view = JSForm.RECORD_VIEW;
jsform.styleName = 'tmpstayle';
jsform.scrollbars = SM_SCROLLBAR.HORIZONTAL_SCROLLBAR_NEVER;
jsform.navigator = SM_DEFAULTS.NONE;
var sFunctionName = '';
for (var index = 1; index <= dsDataset.getMaxRowIndex(); index++) {
var row = dsDataset.getRowAsArray(index);
sFunctionName = row[2];
var jsButton = jsform.newButton(row[0], (2 + (index * 120)), 10, 110, 20, '');
jsButton.onAction = jsform.newMethod('function row[2]() { forms.frm_main.elements.tab_main.removeAllTabs(); forms.frm_main.elements.tab_main.addTab(form_name); }');
jsButton.styleClass = 'tab';
jsButton.showClick = false;
}
elements.tab_main.addTab(sNavigationForm);
The dataset contains a list of cloumns (label_name, form_name, function_name);
I am tring to set the value of function_name (row[2]) as the name of the function set to the onAction() method of the button. How do I set the function name (in the loop)? Because, the name has to be dynamic.
I get the following error: method argument not a jsmethod
I also need to create more than one button (in a loop). How do I name the jsButton in the loop? Because the name has to be dynamic.
Regards,
Hareendra