-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo_uxmultidate.js
86 lines (73 loc) · 2.08 KB
/
demo_uxmultidate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* MultiDate input field demo application.
*
* Version 0.99
*
* Copyright (c) 2011-2012 Alexander Tokarev.
*
* This code is licensed under the terms of the Open Source LGPL 3.0 license.
* Commercial use is permitted to the extent that the code/component(s) do NOT
* become part of another Open Source or Commercially licensed development library
* or toolkit without explicit permission.
*
* License details: http://www.gnu.org/licenses/lgpl.html
*/
Ext.Loader.setConfig({
enabled: true,
disableCaching: true,
paths: {
'Ext.ux': 'ux'
}
});
Ext.require([
'Ext.ux.form.field.MultiDate'
]);
var store, panel;
Ext.onReady(function() {
Ext.tip.QuickTipManager.init();
panel = Ext.create('Ext.form.Panel', {
width: 200,
height: 200,
id: 'formPanel',
layout: 'vbox',
defaults: {
autoScroll: true,
bodyPadding: 8,
listeners: {
specialkey: function(form, event) {
if (event.getKey() === event.ENTER) {
form.up().down('#validateButton').handler();
};
}
}
},
position: 'absolute',
x: 20,
y: 20,
items: [{
xtype: 'multidatefield',
id: 'multiDateField',
allowBlank: false,
multiValue: true,
submitFormat: 'Y-m-d',
submitRangeSeparator: '/',
}, {
xtype: 'button',
id: 'validateButton',
text: 'Validate',
handler: function() {
var form, field;
form = Ext.getCmp('formPanel').getForm();
field = Ext.getCmp('multiDateField');
if ( form.isValid() ) {
var values = form.getValues();
alert('Form is valid: ' + Ext.JSON.encode(values[ field.inputId ]));
}
else {
alert('Form is invalid');
};
}
}],
renderTo: Ext.getBody()
});
});