Create a 'Reset Form' button » History » Version 1
Anonymous, 26/05/2015 18:25
1 | 1 | Anonymous | h1. Create a 'Reset Form' button |
---|---|---|---|
2 | 1 | Anonymous | |
3 | 1 | Anonymous | > *NOTE* : This change refers to Sitools2 - v2.4 |
4 | 1 | Anonymous | |
5 | 1 | Anonymous | The 'Reset Form' button is created beside the 'Search' one, and it invokes a generic @resetToDefault()@ function for all the components of the form. |
6 | 1 | Anonymous | |
7 | 1 | Anonymous | !resetForm_btn.png! |
8 | 1 | Anonymous | |
9 | 1 | Anonymous | To enable it, the following lines of code should be added to |
10 | 1 | Anonymous | |
11 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-user/js/components/forms/mainContainer.js@d45a7442#L143 |
12 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-user/js/components/forms/projectForm.js@d45a7442#L236 |
13 | 1 | Anonymous | |
14 | 1 | Anonymous | <pre><code class="js"> |
15 | 1 | Anonymous | this.resetFormButton = new Ext.Button({ |
16 | 1 | Anonymous | text : 'Reset Form', |
17 | 1 | Anonymous | scope : this, |
18 | 1 | Anonymous | iconCls : 'x-btn-reset', |
19 | 1 | Anonymous | handler : function () { |
20 | 1 | Anonymous | var containers = this.find("stype", 'sitoolsFormContainer'); |
21 | 1 | Anonymous | Ext.each(containers, function (container) { |
22 | 1 | Anonymous | if(Ext.isFunction(container.resetToDefault)){ |
23 | 1 | Anonymous | container.resetToDefault(); |
24 | 1 | Anonymous | } |
25 | 1 | Anonymous | }, this); |
26 | 1 | Anonymous | } |
27 | 1 | Anonymous | }); |
28 | 1 | Anonymous | </code></pre> |
29 | 1 | Anonymous | |
30 | 1 | Anonymous | Then, @resetToDefault()@ is declared specifically for each component and added at the end of their JavaScript files: |
31 | 1 | Anonymous | |
32 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/BooleanCheckBox.js@d45a7442#L81 |
33 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/CheckBox.js@d45a7442#L103 |
34 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/ConeSearch.js@d45a7442#L350 |
35 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/DateBetween.js@d45a7442#L234 |
36 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/ListBoxMultiple.js@d45a7442#L153 |
37 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/Listbox.js@d45a7442#L153 |
38 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/NumberBetween.js@d45a7442#L260 |
39 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/NumberFieldUser.js@d45a7442#L154 |
40 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/OneOrBetween.js@d45a7442#L220 |
41 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/PlanckType.js@d45a7442#L147 |
42 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/Radio.js@d45a7442#L118 |
43 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/js/forms/components/textfield.js@d45a7442#L137 |
44 | 1 | Anonymous | |
45 | 1 | Anonymous | |
46 | 1 | Anonymous | Finally, the icon and button style are declared in the CSS file: |
47 | 1 | Anonymous | |
48 | 1 | Anonymous | source:git_sitools_idoc|szcluster-db/workspace/client-public/res/css/desktop.css@d45a7442#L1479 |
49 | 1 | Anonymous | |
50 | 1 | Anonymous | <pre><code class="css"> |
51 | 1 | Anonymous | button.x-btn-reset{ |
52 | 1 | Anonymous | font-size: 1.2em; |
53 | 1 | Anonymous | font-weight: normal; |
54 | 1 | Anonymous | background-image: url("/sitools/common/res/images/icons/clean.png"); |
55 | 1 | Anonymous | } |
56 | 1 | Anonymous | </code></pre> |