Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.8 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.onReady(function(){
  8. Ext.QuickTips.init();
  9. // turn on validation errors beside the field globally
  10. Ext.form.Field.prototype.msgTarget = 'side';
  11. var fs = new Ext.FormPanel({
  12. frame: true,
  13. title:'XML Form',
  14. labelAlign: 'right',
  15. labelWidth: 85,
  16. width:340,
  17. waitMsgTarget: true,
  18. // configure how to read the XML Data
  19. reader : new Ext.data.XmlReader({
  20. record : 'contact',
  21. success: '@success'
  22. }, [
  23. {name: 'first', mapping:'name/first'}, // custom mapping
  24. {name: 'last', mapping:'name/last'},
  25. 'company', 'email', 'state',
  26. {name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types
  27. ]),
  28. // reusable eror reader class defined at the end of this file
  29. errorReader: new Ext.form.XmlErrorReader(),
  30. items: [
  31. new Ext.form.FieldSet({
  32. title: 'Contact Information',
  33. autoHeight: true,
  34. defaultType: 'textfield',
  35. items: [{
  36. fieldLabel: 'First Name',
  37. emptyText: 'First Name',
  38. name: 'first',
  39. width:190
  40. }, {
  41. fieldLabel: 'Last Name',
  42. emptyText: 'Last Name',
  43. name: 'last',
  44. width:190
  45. }, {
  46. fieldLabel: 'Company',
  47. name: 'company',
  48. width:190
  49. }, {
  50. fieldLabel: 'Email',
  51. name: 'email',
  52. vtype:'email',
  53. width:190
  54. },
  55. new Ext.form.ComboBox({
  56. fieldLabel: 'State',
  57. hiddenName:'state',
  58. store: new Ext.data.ArrayStore({
  59. fields: ['abbr', 'state'],
  60. data : Ext.exampledata.states // from states.js
  61. }),
  62. valueField:'abbr',
  63. displayField:'state',
  64. typeAhead: true,
  65. mode: 'local',
  66. triggerAction: 'all',
  67. emptyText:'Select a state...',
  68. selectOnFocus:true,
  69. width:190
  70. }),
  71. new Ext.form.DateField({
  72. fieldLabel: 'Date of Birth',
  73. name: 'dob',
  74. width:190,
  75. allowBlank:false
  76. })
  77. ]
  78. })
  79. ]
  80. });
  81. // simple button add
  82. fs.addButton('Load', function(){
  83. fs.getForm().load({url:'xml-form.xml', waitMsg:'Loading'});
  84. });
  85. // explicit add
  86. var submit = fs.addButton({
  87. text: 'Submit',
  88. disabled:true,
  89. handler: function(){
  90. fs.getForm().submit({url:'xml-errors.xml', waitMsg:'Saving Data...', submitEmptyText: false});
  91. }
  92. });
  93. fs.render('form-ct');
  94. fs.on({
  95. actioncomplete: function(form, action){
  96. if(action.type == 'load'){
  97. submit.enable();
  98. }
  99. }
  100. });
  101. });
  102. // A reusable error reader class for XML forms
  103. Ext.form.XmlErrorReader = function(){
  104. Ext.form.XmlErrorReader.superclass.constructor.call(this, {
  105. record : 'field',
  106. success: '@success'
  107. }, [
  108. 'id', 'msg'
  109. ]
  110. );
  111. };
  112. Ext.extend(Ext.form.XmlErrorReader, Ext.data.XmlReader);