Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Gitlab has been updated. More info
here
.
Show more breadcrumbs
w2pext
plugin_dbui
Commits
8894c69d
Commit
8894c69d
authored
15 years ago
by
Renaud Le Gac
Browse files
Options
Downloads
Patches
Plain Diff
Introduce the App.form.ComboBox.
parent
6c38485d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
controllers/default.py
+1
-0
1 addition, 0 deletions
controllers/default.py
static/appjs/appcombobox.js
+81
-0
81 additions, 0 deletions
static/appjs/appcombobox.js
static/script/combo_2.js
+4
-36
4 additions, 36 deletions
static/script/combo_2.js
with
86 additions
and
36 deletions
controllers/default.py
+
1
−
0
View file @
8894c69d
...
...
@@ -73,6 +73,7 @@ def index():
os
.
path
.
join
(
base
,
'
static
'
,
'
appjs
'
,
'
combobox.js
'
),
os
.
path
.
join
(
base
,
'
static
'
,
'
appjs
'
,
'
entryform.js
'
),
os
.
path
.
join
(
base
,
'
static
'
,
'
appjs
'
,
'
vieweditgrid.js
'
),
os
.
path
.
join
(
base
,
'
static
'
,
'
appjs
'
,
'
appcombobox.js
'
),
os
.
path
.
join
(
base
,
'
static
'
,
'
appjs
'
,
'
appgrid.js
'
),
os
.
path
.
join
(
base
,
'
static
'
,
'
appjs
'
,
'
appgridroweditor.js
'
),
os
.
path
.
join
(
base
,
'
static
'
,
'
appjs
'
,
'
appgridrowcontextmenu.js
'
),
...
...
This diff is collapsed.
Click to expand it.
static/appjs/appcombobox.js
0 → 100644
+
81
−
0
View file @
8894c69d
/**
* A pre-configured combobox reading its data in the database.
* Design to work with the class HttpDb on the server side.
*
* MANDATORY PROPERTIES:
* - table the name of the database table
* - displayField field of the table shown in the combobox
* - valueField field of the table return by the combobox
*
* All configuration properties of Ext.form.ComboBox are understood.
*
* @extends Ext.form.ComboBox
* @author $Author$
* @version $Id$
*
*/
Ext
.
namespace
(
'
App.form
'
);
App
.
form
.
ComboBox
=
Ext
.
extend
(
Ext
.
form
.
ComboBox
,
{
/**
* @cfg {String} the database table where data are retrieve.
* This parameter is send to the server as a baseParams.
* This parameter is mandatory.
*/
table
:
null
,
/**
* @cfg {Boolean} actiate the debug on the server side
* This parameter is send to the server as a baseParams.
*/
debug
:
false
,
/**
* Predefined setting
*
*/
mode
:
'
remote
'
,
selectOnFocus
:
true
,
triggerAction
:
'
all
'
,
typeAhead
:
true
,
/**
* The constructor
* @param {Object} config
*/
constructor
:
function
(
config
){
Ext
.
apply
(
this
,
config
);
// defined the empty text from the field label
if
(
this
.
fieldLabel
&&
!
this
.
emptyText
){
this
.
emptyText
=
"
Select a
"
+
this
.
fieldLabel
+
"
...
"
;
}
// setup the store if not defined by the user
// the autoLoad property set at true is mandatory to
// set a value when the combobox is not yet expend
if
(
!
this
.
store
)
{
this
.
store
=
new
App
.
data
.
JsonStore
({
url
:
App
.
dburl
,
table
:
this
.
table
,
tableFields
:
[
this
.
valueField
,
this
.
displayField
],
sortInfo
:
{
field
:
this
.
displayField
},
debug
:
this
.
debug
,
autoLoad
:
true
,
});
}
// construct the underlying class. DON'T MOVE
App
.
ComboBox
.
superclass
.
constructor
.
apply
(
this
);
// This few lines are required to set a value
// when the combobox is not yet expend
this
.
store
.
on
(
'
load
'
,
function
(){
this
.
setValue
(
this
.
getValue
());
},
this
);
},
});
Ext
.
reg
(
'
xcombobox
'
,
App
.
form
.
ComboBox
);
This diff is collapsed.
Click to expand it.
static/script/combo_2.js
+
4
−
36
View file @
8894c69d
...
...
@@ -6,16 +6,8 @@
* $Id$
*
*/
Ext
.
namespace
(
'
App.combo
'
);
App
.
combo
.
ComboBox
=
Ext
.
extend
(
Ext
.
form
.
ComboBox
,
{
mode
:
'
remote
'
,
selectOnFocus
:
true
,
triggerAction
:
'
all
'
,
typeAhead
:
true
,
});
/**
* main function
* The scope, this, contains the models return by the server
...
...
@@ -24,42 +16,18 @@ App.combo.ComboBox = Ext.extend(Ext.form.ComboBox, {
var
main
=
function
(){
// console.dir(this);
var
model
=
this
.
viewedit
.
rpmCategories
.
store
;
console
.
dir
(
model
);
var
store
=
new
App
.
data
.
JsonStore
({
url
:
App
.
dburl
,
table
:
model
.
table
,
tableFields
:
model
.
tableFields
,
debug
:
true
,
autoLoad
:
true
,
});
// Here is the trick to set properly a user value
// in the initialization phase.
// the store have to be in autoLoad mode to force
// the loading of the store.
// then when it is load apply the user value.
// Trick found on the extjs forum.
// However when the user will select a new value the
// store will be load again !
store
.
on
(
"
load
"
,
function
(){
combo
.
setValue
(
combo
.
getValue
());
});
var
combo
=
new
App
.
combo
.
ComboBox
({
var
combo
=
new
App
.
form
.
ComboBox
({
table
:
"
rpmCategories
"
,
displayField
:
"
category
"
,
fieldLabel
:
"
Category
"
,
valueField
:
"
id
"
,
hiddenName
:
"
idcategory
"
,
emptyText
:
"
Select a category...
"
,
store
:
store
,
fieldLabel
:
"
Category
"
,
});
combo
.
on
(
"
select
"
,
function
(){
console
.
log
(
this
.
getValue
());
});
form
=
new
Ext
.
FormPanel
({
renderTo
:
"
appmain
"
,
bodyStyle
:
'
padding:5px 5px 0
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment