根据输入自动匹配搜索展示的 combo实例
2014-01-05 23:09
316 查看
根据输入自动匹配搜索展示的 combo实例。
MemberEditGrid = Ext.extend(Ext.grid.Panel, { _proId:0, constructor : function(_config) { if (_config == null) _config = {}; Ext.apply(this, _config); this.canFlag = false; this.monCorr = true; this.fzrId = null; this.jhyId = null; // if( this._tab._topPanel._grid.getSelectionModel().selected.length > 0) // this._proId = this._tab._topPanel._grid.getSelectionModel().selected.items[0].get('guId'); this['rowEditing'] = Ext.create('Ext.grid.plugin.RowEditing', { clicksToMoveEditor: 1, autoCancel: false }); this._baseParam = { process : this._process, start : 1 }; if(this._winProId) this._baseParam.proId = this._winProId; this["store"] = { autoLoad : true, proxy : { type : 'ajax', url : "xmgk/xm-member-manage.action", extraParams : this._baseParam, reader : { type : 'json', root : 'rows', totalProperty : "totalCount" } }, model : 'XmMember', listeners : { 'load' : { fn : this.loadHander, scope : this } } }; this['columns'] = [ { header : "角色", dataIndex : "ryxz" // editor: { // // allowBlank: false // } }, { text : '姓名', flex : 1, dataIndex : 'name', editor: { xtype:'combo', queryMode : 'remote', columnWidth : .33, typeAhead:true, labelAlign : 'right', fzrId:this.fzrId, jhyId:this.jhyId, // multiSelect:true, anchor : '95%', triggerAction : "all", // 显示所有数据 displayField : "userName", // 要显示的值 valueField : "userName",// 要隐藏实际的值 queryParam : 'name', forceSelection : true, hideTrigger : true, resizable : false, editable : true, queryDelay : 500, enableKeyEvents : true, minChars : 1, listConfig : { loadingText : '正在加载中...' }, store : new Ext.data.Store( { autoLoad : true, proxy : { type : 'ajax', url : 'sys/user-info-manage!getComboUserName.action', extraParams:{ // orgGuId : currUser.get('orgGuId') } }, model : 'UserInfo' }), // listeners : { // 'blur' : { // fn : this.changeHandler, // scope : this // } // }, allowBlank: false // , // listeners : { // 'blur' : { // fn : function(_field,_a,_b){ // // ajaxRequest( { // url : 'sys/user-info-manage!checkUserName.action', // params : { // name : _field.value // }, // callBack : function(returnData) { // if(returnData.data=='error'){ // warningMesg({ // msg :'无此用户,请确认!' // }); // // _field.focus(false,100); // return false; // }else // return true; // } // }); // }, // scope : this // } // } } }, { text : '单位', flex : 1, dataIndex : 'danwei', editor: { // allowBlank: false } }, { text : '性别', flex : 1, //id : 'sex', dataIndex : 'sex', editor: { // allowBlank: false } }, { text : '出生年月', flex : 1, xtype : 'datecolumn', format : 'Y-m', dataIndex : 'csny', editor: { xtype: 'datefield', format: 'Y-m' // allowBlank: false } }, { text : '技术职称', flex : 2, dataIndex : 'jszc', editor: {} } ,{ text : '专业', flex : 1, dataIndex : 'zy', editor: { // allowBlank: false } }, { text : '承担的主要工作', flex : 2, dataIndex : 'cddzygz', editor: {} } ,{ text : '投入月数', flex : 1, dataIndex : 'trys', editor: { // allowBlank: false } }] MemberEditGrid.superclass.constructor.call(this, { height : 210, width :window.screen.width * 0.8, autoScroll : true, //id:'memb', plugins: [this.rowEditing], tbar : [ { text : "增加人员", iconCls : "tbnt_addrow", handler : this.onAddRow, scope : this }, "-", { text : "删除人员", iconCls : "tbnt_del", handler : this.onDelRow, scope : this },"-", { text : "保存", iconCls : "tbnt_save", handler : this.onSave, scope : this }], viewConfig : { stripeRows : true, enableTextSelection : true } }); }, loadHander : function(_load,_datas){ if(this._period> this.store.totalCount){ var _size = this._period -this.store.totalCount; for(var i=0;i<_size;i++) this.store.add(new XmMember()); } var _index = this.store.getCount(); if(_index == 0) { var _ps = new XmMember(); _ps.data.ryxz = '项目经理'; _ps.data.orders = 0; this.store.insert(0,_ps); _ps = new XmMember(); _ps.data.ryxz = '项目计划员'; _ps.data.orders = 1; this.store.insert(1,_ps); } }, onAddRow : function(){ var _ps = new XmMember(); var _index = this.store.getCount(); if(_index == 0) { _ps.data.ryxz = '项目经理'; _ps.data.orders = 0; } else if(_index == 1) { _ps.data.ryxz = '项目计划员'; _ps.data.orders = 1; } else { _ps.data.ryxz = '项目成员'; _ps.data.orders = _index; } this.store.insert(_index,_ps); }, onSave : function(){ var guId = this._winProId; var _res= this.store.data.items; var _data = ''; Ext.each(_res,function(_item,_index,_allItems){ if(_item.get("name").length>0){ if(_data.length==0){ _data+='['; } if(_data.length>1) _data+=','; _data+= Ext.encode(_item.data); //_count++; } else { alert('必须填写姓名!'); return; } }); if(_data.length>0) _data+=']'; else{ warningMesg({ msg : '请录入人员信息!' }); return; } var _grid = this; ajaxRequest( { url : 'xmgk/xm-member-manage!save.action', params : { proId:guId, data : _data }, callBack : function(returnData) { _grid.store.loadPage(1); } }); }, changeHandler : function(_combo,_record,_op) { var guId = _combo.lastSelection[0].data.guId; if(_combo.ownerCt.items.items[0].value == '项目经理') { _combo.fzrId = guId; } if(_combo.ownerCt.items.items[0].value == '项目计划员') { _combo.jhyId = guId; } // var combo; // alert(); console.log(_combo.jhyId); console.log(_combo.jhyId); }, onDelRow : function(){ var _selRow = this.getSelectionModel().selected.items[0]; var _grid = this; if(_selRow==null){ warningMesg({msg : '请选择人员!'}); return ; } var _names = getGridValues(this,'ryxz'); if(_names.indexOf('项目经理')!= -1 || _names.indexOf('项目计划员')!= -1) { warningMesg({msg : '只能删除项目成员!'}); return ; } var _guIds = getGridValues(this,'guId'); askMesg({ msg : '确定删除该人员信息?', fn : function(){ if(_selRow.get('guId')>0){ ajaxRequest( { url : 'xmgk/xm-member-manage!delete.action', params : { guIds : _guIds }, callBack : function(returnData) { _grid.store.remove(_selRow); } }); }else _grid.store.remove(_selRow); } }); } });后台代码 就是根据 name 进行like匹配搜索即可,此处省略。
相关文章推荐
- js处理根据输入的身份证号自动匹配出生年月
- flex----遍历树Tree,根据输入的名称搜索树节点,并展示该节点
- php+ajax实时输入自动搜索匹配的方法
- Android实现根据用户输入自动搜索
- jquery 根据输入框输入的值 自动计算其他值的实例
- Android实现根据用户输入自动搜索
- ExpandableListView 根据输入的名称搜索对应的内容并展示,点击可打开二级列表
- php+ajax实时输入自动搜索匹配的方法
- puppeteer 实例:自动输入表单并提交搜索显示新的页面
- [置顶] Android实现根据用户输入自动搜索
- JCombobox实现根据输入自动匹配
- 根据服务器端返回的字符数组,展示字符串标签,需要涉及字符串长度处理以及字符串换行,字符串不够一行自动跳到第二行的逻辑
- [JS]根据格式字符串分析日期(MM与自动匹配两位的09和一位的9),货币分析成浮点数
- android学习之实现动态自动匹配输入
- 搜索框输入内容回车后如何触发搜索按钮,自动打开网页
- 可输入、自动匹配的下拉框
- php+ajax做仿百度搜索下拉自动提示框(有实例)
- UISearchDisplayController(iOS < 8.0)实例应用实现搜索功能和VC展示效果, 以及代理方法的介绍
- AutoCompleteTextView实现自动匹配输入内容
- [原]考试系统——可输入并自动匹配的下拉框(二)——JQuery Easy UI框架