editor.js
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:3k
源码类别:

JavaScript

开发平台:

JavaScript

  1. /*!  * Ext JS Library 3.1.0  * Copyright(c) 2006-2009 Ext JS, LLC  * licensing@extjs.com  * http://www.extjs.com/license  */ Ext.onReady(function(){
  2.     var ct = new Ext.form.FormPanel({
  3.         renderTo: 'container',
  4.         width: 700,
  5.         height: 400,
  6.         title: 'User Details',
  7.         defaultType: 'textfield',
  8.         padding: 10,
  9.         labelWidth: 90,
  10.         items: [{
  11.             fieldLabel: 'First Name'
  12.         }, {
  13.             fieldLabel: 'Middle Name'
  14.         }, {
  15.             fieldLabel: 'Last Name'
  16.         }, {
  17.             xtype: 'datefield',
  18.             fieldLabel: 'D.O.B'
  19.         }],
  20.         listeners: {
  21.             afterrender: function(form){
  22.                 var cfg = {
  23.                     shadow: false,
  24.                     completeOnEnter: true,
  25.                     cancelOnEsc: true,
  26.                     updateEl: true,
  27.                     ignoreNoChange: true
  28.                 };
  29.                 var labelEditor = new Ext.Editor(Ext.apply({
  30.                     alignment: 'l-l',
  31.                     listeners: {
  32.                         beforecomplete: function(ed, value){
  33.                             if(value.charAt(value.length - 1) != ':'){
  34.                                 ed.setValue(ed.getValue() + ':');
  35.                             }
  36.                             return true;
  37.                         },
  38.                         complete: function(ed, value, oldValue){
  39.                             Ext.example.msg('Label Changed', '"{0}" changed to "{1}"', oldValue, value);
  40.                         }
  41.                     },
  42.                     field: {
  43.                         allowBlank: false,
  44.                         xtype: 'textfield',
  45.                         width: 90,
  46.                         selectOnFocus: true
  47.                     }
  48.                 }, cfg));
  49.                 form.body.on('dblclick', function(e, t){
  50.                     labelEditor.startEdit(t);
  51.                 }, null, {
  52.                     delegate: 'label.x-form-item-label'
  53.                 });
  54.                 var titleEditor = new Ext.Editor(Ext.apply({
  55.                     cls: 'x-small-editor',
  56.                     alignment: 'bl-bl?',
  57.                     offsets: [0, 3],
  58.                     listeners: {
  59.                         complete: function(ed, value, oldValue){
  60.                             Ext.example.msg('Title Changed', '"{0}" changed to "{1}"', oldValue, value);
  61.                         }
  62.                     },
  63.                     field: {
  64.                         width: 110,
  65.                         triggerAction: 'all',
  66.                         xtype: 'combo',
  67.                         editable: false,
  68.                         forceSelection: true,
  69.                         store: ['User Details', 'Developer Details', 'Manager Details']
  70.                     }
  71.                 }, cfg));
  72.                 form.header.child('.x-panel-header-text').on('dblclick', function(e, t){
  73.                     titleEditor.startEdit(t);
  74.                 });
  75.             }
  76.         }
  77.     });
  78. });