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
Show more breadcrumbs
w2pext
plugin_dbui
Commits
b255e54a
Commit
b255e54a
authored
8 years ago
by
LE GAC Renaud
Browse files
Options
Downloads
Patches
Plain Diff
Update Table.js to reset it properly.
parent
ccd505b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!30
Release 0.9.3
,
!29
28 grid filter with dict list
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
static/plugin_dbui/src/form/field/Table.js
+47
-12
47 additions, 12 deletions
static/plugin_dbui/src/form/field/Table.js
with
47 additions
and
12 deletions
static/plugin_dbui/src/form/field/Table.js
+
47
−
12
View file @
b255e54a
...
...
@@ -2,11 +2,11 @@
* Form field to render database field with the type JSON as a table.
* The size of the table is numRows x numColumns. It is fixed.
*
* The widget renders a JSON object which if is a
list
(nRow) of
list
(nCol).
* The widget renders a JSON object which if is a
n array
(nRow) of
array
(nCol).
* Possible values are boolean, date, float and string objects.
*
* The interface is less rich than the one of the Ext.form.field.Base since
* it only contains the basic methods
getErrors,
getValue and setValue.
* it only contains the basic methods getValue and setValue.
*
* @since 0.9.3
*
...
...
@@ -75,11 +75,9 @@ Ext.define('Dbui.form.field.Table', {
initComponent
:
function
()
{
var
me
=
this
,
data
=
[],
header
=
me
.
header
||
[],
numColumns
=
me
.
numColumns
,
numRows
=
me
.
numRows
,
cfgColumns
,
grid
,
i
,
name
,
row
;
cfgColumns
,
grid
,
i
,
name
;
// field"s name for the store, data index for the column
// as well as column labels: (A, B, C , ....) or user defined
...
...
@@ -89,16 +87,10 @@ Ext.define('Dbui.form.field.Table', {
}
}
// dummy data for the local store
for
(
i
=
0
;
i
<
numRows
;
i
+=
1
)
{
row
=
new
Array
(
numColumns
);
data
.
push
(
row
);
}
// instantiate the store
me
.
store
=
Ext
.
create
(
'
Ext.data.ArrayStore
'
,
{
fields
:
header
,
data
:
d
ata
data
:
me
.
initD
ata
()
});
// first column of the grid contains the row number
...
...
@@ -124,6 +116,7 @@ Ext.define('Dbui.form.field.Table', {
// when a cell is edited it is not marked dirty
me
.
items
=
[{
columns
:
cfgColumns
,
columnLines
:
true
,
hideHeaders
:
me
.
hideHeader
,
plugins
:
{
ptype
:
'
cellediting
'
,
...
...
@@ -209,6 +202,26 @@ Ext.define('Dbui.form.field.Table', {
return
data
;
},
/**
* Generate the data block corresponding to an empty table
* @return {Array[]} data
*/
initData
:
function
()
{
"
use strict
"
;
var
me
=
this
,
data
=
[],
numColumns
=
me
.
numColumns
,
i
,
row
;
for
(
i
=
0
;
i
<
me
.
numRows
;
i
+=
1
)
{
row
=
new
Array
(
numColumns
);
data
.
push
(
row
);
}
return
data
;
},
/**
* Block the context menu.
*
...
...
@@ -241,6 +254,28 @@ Ext.define('Dbui.form.field.Table', {
me
.
fireEvent
(
'
change
'
,
me
);
},
/**
* Reset the field to the originalValue.
* Supersede the mixin method to initialize the table with empty data.
*
*/
reset
:
function
()
{
"
use strict
"
;
var
me
=
this
,
oriVal
=
me
.
originalValue
;
console
.
log
(
"
reset
"
,
oriVal
);
// check that original value is defined
if
(
!
(
Ext
.
isArray
(
oriVal
)
&&
oriVal
.
length
===
me
.
numColumns
))
{
me
.
originalValue
=
me
.
initData
();
}
// rest of the processing by the mixing Field
me
.
mixins
.
field
.
reset
.
call
(
me
,
arguments
);
},
/**
* Set the value for the table.
*
...
...
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