技术开发 频道

Ext 2.0使用:组件开发模式

以下是查找用户对话窗体:
1/**//** 2 * @author Terry 3 */ 4 5EasyNet.SearchUserWindow = Ext.extend(Ext.Window, { 6 width: 350, 7 height: 250, 8 resizable: false, 9 layout: 'form', 10 plain: true, 11 bodyStyle: 'padding:5px;', 12 buttonAlign: 'right', 13 modal:true, 14 title: '查找用户', 15 closeAction: 'hide', 16 buttons: [{ 17 text: '确定' 18 }, { 19 text: '取消' 20 }], 21 22 initComponent: function(){ 23 this.items = [{ 24 layout: 'column', 25 baseCls: 'x-plain', 26 items: [{ 27 columnWidth:0.08, 28 layout: 'form', 29 baseCls: 'x-plain', 30 items: [{ 31 hideLabel: true, 32 xtype: 'checkbox', 33 name: 'ckLoginName' 34 }, { 35 hideLabel: true, 36 xtype: 'checkbox', 37 name: 'ckUserName' 38 }, { 39 hideLabel: true, 40 xtype: 'checkbox', 41 name: 'ckDate' 42 }] 43 }, { 44 columnWidth: 0.8, 45 layout: 'form', 46 baseCls: 'x-plain', 47 items: [{ 48 xtype: 'textfield', 49 fieldLabel: '登录名称', 50 emptyText: '登录名称', 51 maxLength: 50, 52 name: 'loginName' 53 }, { 54 xtype: 'textfield', 55 fieldLabel: '用户名称', 56 emptyText: '用户名称', 57 maxLength: 50, 58 name: 'userName' 59 }, { 60 xtype: 'datefield', 61 fieldLabel: '起始时间', 62 emptyText: '年-月-日', 63 format: 'Y-m-d', 64 width: 130, 65 name: 'bDate' 66 }, { 67 xtype: 'datefield', 68 fieldLabel: '起始时间', 69 emptyText: '年-月-日', 70 format: 'Y-m-d', 71 width: 130, 72 name: 'eDate' 73 }] 74 }] 75 }]; 76 77 Easy.SearchUserWindow.superclass.initComponent.call(this); 78 }, 79 80 onRender: function(ct, position){ 81 EasyNet.SearchUserWindow.superclass.onRender.call(this, ct, position); 82 this.buttons[0].on('click', this.onSearch, this); 83 this.buttons[1].on('click', this.onCancel, this); 84 85 }, 86 87 onSearch: function(){ 88 this.loadData(); 89 }, 90 91 onCancel: function(){ 92 if(this.closeAction == 'hide'){ 93 this.hide(); 94 } 95 else if(this.closeAction == 'close'){ 96 this.close(); 97 } 98 }, 99 100 getValue: function(){ 101 return { 102 ckLoginName: this.find('name', 'ckLoginName')[0].getValue(), 103 ckUserName: this.find('name', 'ckUserName')[0].getValue(), 104 loginName: this.find('name', 'loginName')[0].getValue(), 105 userName: this.find('name', 'userName')[0].getValue(), 106 bDate: this.find('name', 'bDate')[0].getValue(), 107 eDate: this.find('name', 'eDate')[0].getValue() 108 } 109 }, 110 111 getCondition: function(){ 112 var o = this.getValue(); 113 var filter ='Status=1'; 114 115 if(o.ckLoginName && o.LoginName != ''){ 116 filter += String.format(' AND LoginName LIKE \'%{0}%\'', o.loginName); 117 } 118 if(o.ckUserName && o.userName != ''){ 119 filter += String.format(' AND UserName LIKE \'%{0}%\'', o.userName); 120 } 121 if(o.ckDate && o.bDate != '' && o.eDate != '' && o.eDate >= o.bDate){ 122 filter += String.format(' AND RegDate BETWEEN \'{0}\' AND \'{1}\'', o.bDate, o.eDate); 123 } 124 125 return { 126 fields: '*', 127 filter: filter 128 } 129 }, 130 131 loadData: function(){ 132 if(this.searchTo){ 133 this.searchTo.store.baseParams = this.getCondition(); 134 this.searchTo.loadData(); 135 } 136 137 this.onCancel(); 138 } 139});

在实际应用中所有数据调用.Net写的Web Service取得。

原文地址

0
相关文章