46a64628007d814610b3a81d76958712cd13c781.svn-base 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.onReady(function() {
  7. Ext.QuickTips.init();
  8. Ext.form.Field.prototype.msgTarget = 'side';
  9. /* Language chooser combobox */
  10. var store = new Ext.data.SimpleStore({
  11. fields : ['code', 'language', 'charset'],
  12. data : Ext.exampledata.languages
  13. // from languages.js
  14. });
  15. var combo = new Ext.form.ComboBox({
  16. store : store,
  17. displayField : 'language',
  18. typeAhead : true,
  19. mode : 'local',
  20. triggerAction : 'all',
  21. emptyText : 'Select a language...',
  22. selectOnFocus : true,
  23. onSelect : function(record) {
  24. window.location.search = Ext.urlEncode({
  25. "lang" : record.get("code"),
  26. "charset" : record.get("charset")
  27. });
  28. }
  29. });
  30. combo.render('languages');
  31. // get the selected language code parameter from url (if exists)
  32. var params = Ext.urlDecode(window.location.search.substring(1));
  33. if (params.lang) {
  34. // check if there's really a language with that language code
  35. record = store.data.find(function(item, key) {
  36. if (item.data.code == params.lang) {
  37. return true;
  38. }
  39. return false;
  40. });
  41. // if language was found in store assign it as current value in
  42. // combobox
  43. if (record) {
  44. combo.setValue(record.data.language);
  45. }
  46. }
  47. /* Email field */
  48. var emailfield = new Ext.FormPanel({
  49. labelWidth : 100, // label settings here cascade
  50. // unless overridden
  51. frame : true,
  52. title : 'Email Field',
  53. bodyStyle : 'padding:5px 5px 0',
  54. width : 360,
  55. defaults : {
  56. width : 220
  57. },
  58. defaultType : 'textfield',
  59. items : [{
  60. fieldLabel : 'Email',
  61. name : 'email',
  62. vtype : 'email'
  63. }]
  64. });
  65. emailfield.render('emailfield');
  66. /* Datepicker */
  67. var datefield = new Ext.FormPanel({
  68. labelWidth : 100, // label settings here cascade
  69. // unless overridden
  70. frame : true,
  71. title : 'Datepicker',
  72. bodyStyle : 'padding:5px 5px 0',
  73. width : 360,
  74. defaults : {
  75. width : 220
  76. },
  77. defaultType : 'datefield',
  78. items : [{
  79. fieldLabel : 'Date',
  80. name : 'date'
  81. }]
  82. });
  83. datefield.render('datefield');
  84. // shorthand alias
  85. var fm = Ext.form, Ed = Ext.grid.GridEditor;
  86. var monthArray = Date.monthNames.map(function(e) {
  87. return [e];
  88. });
  89. var ds = new Ext.data.Store({
  90. proxy : new Ext.data.PagingMemoryProxy(monthArray),
  91. reader : new Ext.data.ArrayReader({}, [{
  92. name : 'month'
  93. }])
  94. });
  95. var cm = new Ext.grid.ColumnModel([{
  96. header : "Months of the year",
  97. dataIndex : 'month',
  98. editor : new Ed(new fm.TextField({
  99. allowBlank : false
  100. })),
  101. width : 240
  102. }]);
  103. cm.defaultSortable = true;
  104. var grid = new Ext.grid.GridPanel({
  105. el : 'grid',
  106. width : 360,
  107. height : 203,
  108. title : 'Month Browser',
  109. store : ds,
  110. cm : cm,
  111. sm : new Ext.grid.RowSelectionModel({
  112. selectRow : Ext.emptyFn
  113. }),
  114. bbar : new Ext.PagingToolbar({
  115. pageSize : 6,
  116. store : ds,
  117. displayInfo : true
  118. })
  119. })
  120. grid.render();
  121. // trigger the data store load
  122. ds.load({
  123. params : {
  124. start : 0,
  125. limit : 6
  126. }
  127. });
  128. });