1
|
* @properties={typeid:35,uuid:"4B1C0A38-1010-4B7B-B71C-3F51F92F2FC4"}
|
2
|
*/
|
3
|
var ___mod_listpicker_init = __mod_listpicker_init();
|
4
|
|
5
|
/**
|
6
|
* @properties={typeid:24,uuid:"72B67D08-8096-4104-88EB-BE86C804854E"}
|
7
|
*/
|
8
|
function __mod_listpicker_init() {
|
9
|
|
10
|
/**
|
11
|
* create a new JSlistpicker Object
|
12
|
* @constructor
|
13
|
*/
|
14
|
JSListpicker = function() {
|
15
|
|
16
|
/**
|
17
|
* JSListPicker
|
18
|
*
|
19
|
* Version 0.9.2
|
20
|
*
|
21
|
* Written by Robert J.C. Ivens
|
22
|
*
|
23
|
* This software is released under the MIT license
|
24
|
* http://www.opensource.org/licenses/mit-license.php
|
25
|
*
|
26
|
* Questions, bugs, feature requests, patches:
|
27
|
* http://www.servoyforge.net/projects/mod-listpicker/
|
28
|
*
|
29
|
*/
|
30
|
|
31
|
this.form = {
|
32
|
name: "mod_listpicker_form", // required, please use a unique name for all your instances
|
33
|
serverName: "", // required
|
34
|
tableName: "", // required
|
35
|
|
36
|
displayColumns: new Array(), // required
|
37
|
columnsToolTips: new Array(), // required (Added by JASM 23-09-2010)
|
38
|
displayTypes: new Array(), // required
|
39
|
displayNames: new Array(), // required
|
40
|
columnWidths: new Array(), // required
|
41
|
rowHeight: 20, // required
|
42
|
searchColumns: new Array(), // required
|
43
|
pickColumn: "", // required
|
44
|
|
45
|
title: "List Of Values",
|
46
|
width: 600, // required
|
47
|
height: 500, // required
|
48
|
stylesheet: "", // you can put here your default stylesheet if you want so you won't have to set it anymore
|
49
|
|
50
|
// Stores the filter param Arrays: [columnNameString,OperatorString,Value]
|
51
|
filterParam: new Array(), // optional
|
52
|
|
53
|
loadAllRecords: false // optional, load all records when no search criteria is given.
|
54
|
|
55
|
}
|
56
|
|
57
|
this.callback = {
|
58
|
// Use either callbackFormName or callbackMethod
|
59
|
formName: "", // required (unless callbackMethod is used)
|
60
|
columnName: "", // required, when using callbackFormName
|
61
|
|
62
|
methodFormName: "", /// optional, leave empty when using global methods
|
63
|
methodName: "", // required (unless callbackFormName is used)
|
64
|
|
65
|
createNewMethod: "" // optional
|
66
|
}
|
67
|
|
68
|
this.buttontext = {
|
69
|
cancel: "Cancel", // optional, for use with i18n
|
70
|
createnew: "Create New" // optional, for use with i18n
|
71
|
}
|
72
|
|
73
|
this.show = function() {
|
74
|
var _oForm,
|
75
|
_oField,
|
76
|
_oLabel,
|
77
|
_nFieldWidth,
|
78
|
_nFormWidth = 0,
|
79
|
i;
|
80
|
|
81
|
// Some crude sanity check of the JSListpicker values
|
82
|
if (!this.form.name ||
|
83
|
!this.form.serverName ||
|
84
|
!this.form.tableName ||
|
85
|
!this.form.displayColumns[0] ||
|
86
|
!this.form.columnsToolTips[0] ||
|
87
|
!this.form.displayNames[0] ||
|
88
|
!this.form.displayTypes[0] ||
|
89
|
!this.form.searchColumns[0] ||
|
90
|
this.form.displayNames.length != this.form.displayColumns.length ||
|
91
|
this.form.displayColumns.length != this.form.columnWidths.length ||
|
92
|
!this.form.pickColumn ||
|
93
|
! (this.form.width > 0) ||
|
94
|
! (this.form.height > 0) ||
|
95
|
(!this.callback.methodName && (!this.callback.formName || !this.callback.columnName))) {
|
96
|
|
97
|
application.output("Listpicker: missing or invalid required values", LOGGINGLEVEL.ERROR);
|
98
|
return; // stop right here
|
99
|
}
|
100
|
|
101
|
// If this (dynamic) form already exists in memory, remove it
|
102
|
if (history.removeForm(this.form.name)) {
|
103
|
solutionModel.removeForm(this.form.name);
|
104
|
}
|
105
|
|
106
|
// create a new listpicker form based on the original form in this module
|
107
|
_oForm = solutionModel.newForm(this.form.name, ("db:/" + this.form.serverName + "/" + this.form.tableName), this.form.stylesheet, false, this.form.width, this.form.height);
|
108
|
_oForm.extendsForm = "mod_listpicker"; // form inheritence, here we get all the settings and objects of the original form
|
109
|
|
110
|
_oLabel = _oForm.newLabel("", 0, 30, 23, this.form.rowHeight, solutionModel.getForm("mod_listpicker").getFormMethod("btnSelect"));
|
111
|
_oLabel.mediaOptions = SM_MEDIAOPTION.CROP
|
112
|
_oLabel.imageMedia = solutionModel.getMedia("btn_select.png")
|
113
|
_oLabel.verticalAlignment = SM_ALIGNMENT.TOP;
|
114
|
_oLabel.anchors = SM_ANCHOR.NORTH | SM_ANCHOR.WEST;
|
115
|
_oLabel.transparent = true;
|
116
|
_oLabel.showClick = false;
|
117
|
_oLabel.showFocus = false;
|
118
|
|
119
|
for ( i = 0; i < this.form.columnWidths.length; i++) {
|
120
|
if ( this.form.columnWidths[i] > -1) {
|
121
|
_nFormWidth += this.form.columnWidths[i];
|
122
|
}
|
123
|
}
|
124
|
|
125
|
_nFieldWidth = ( (this.form.width - _nFormWidth - 16) / this.form.displayColumns.length);
|
126
|
|
127
|
// place the fields on the form
|
128
|
for ( i = 0; i < this.form.displayColumns.length; i++) {
|
129
|
if ( this.form.columnWidths[i] > -1){
|
130
|
_oField = _oForm.newField(this.form.displayColumns[i], SM_DISPLAYTYPE[this.form.displayTypes[i]], i + 1, (31 + i), this.form.columnWidths[i], this.form.rowHeight);
|
131
|
} else {
|
132
|
_oField = _oForm.newField(this.form.displayColumns[i], SM_DISPLAYTYPE[this.form.displayTypes[i]], i + 1, (31 + i), _nFieldWidth, this.form.rowHeight);
|
133
|
}
|
134
|
_oField.titleText = this.form.displayNames[i];
|
135
|
_oField.toolTipText = this.form.columnsToolTips[i]; // Added by JASM 23-09-2010
|
136
|
_oField.editable = false;
|
137
|
_oField.tabSeq = -2;
|
138
|
_oField.borderType = 'EmptyBorder, 0, 0, 0, 0';
|
139
|
_oField.margin = "0,2,0,0"; // little margin on the left
|
140
|
// Anchor the last field
|
141
|
if ( this.form.columnWidths[i] == -1) {
|
142
|
_oField.anchors = SM_ANCHOR.WEST | SM_ANCHOR.EAST;
|
143
|
}
|
144
|
}
|
145
|
|
146
|
// Pass the JSListpicker object to the form-variable for further processing (like when clicking on form buttons)
|
147
|
forms[this.form.name]._g_oListpicker = this;
|
148
|
|
149
|
// Show the form in a modal dialog
|
150
|
if (application.getApplicationType() == APPLICATION_TYPES.WEB_CLIENT) {
|
151
|
// add some width to the dialog or else the form will show scrollbars
|
152
|
application.showFormInDialog(forms[this.form.name], -1, -1, this.form.width + 25, this.form.height, this.form.title, false, false, this.form.name, true);
|
153
|
} else {
|
154
|
application.showFormInDialog(forms[this.form.name], -1, -1, this.form.width, this.form.height, this.form.title, false, false, this.form.name, true);
|
155
|
}
|
156
|
}
|
157
|
|
158
|
}
|
159
|
}
|