Extjs SearchField 应用

// Search Field 的应用
// <1>导入JS
<script type="text/javascript" src="/js/Extjs/ux/SearchField.js"></script>

// <2> 定义SearchField组件放到tbar上面
var searchField = new Ext.ux.form.SearchField({
                width:140,
                store: store,
                id:'searchField',
                paramName: 'q',
                // Add event
                onTrigger2Click:function(f,e){  // Search button event
                        var v = this.getRawValue();  // 获取搜索框输入的值
                        // 拼接条件-----------------------BEG
                        var filterValue = "[";
                        var rowIndex = keyNameStore.getCount();
                        for(var i=0;i<rowIndex;i++){
                            var record = keyNameStore.getAt(i);
                            var fields = Ext.util.JSON.encode(record.data);
                            var fieldObj = Ext.util.JSON.decode(fields);
                            filterValue += "{keyName:"+"'"+fieldObj.value+"',";
                            filterValue += "logic:"+"'like',";
                            filterValue += "keyValue:"+"'"+v+"',";
                            filterValue += "keyType:"+"'stirng'}";
                            if(i!=(rowIndex-1)){
                              filterValue+= ",";
                            }else{
                              filterValue+= "]";
                            }
                         // 拼接条件-----------------------END
                        } //for--------END
      // 设置传回后台的参数                  
      store.baseParams['filterinfo'] = Ext.util.JSON.encode(Ext.util.JSON.decode(filterValue));
      store.load({ params: { start: 0, limit: pagesize} });
                  } // onTrigger2Click:function ---END
});
//-----------------------------UPD:Select record operation-----------------------END

// 辅助:
// 可调用SearchFiled  onTrigger2Click方法
var searchFiledObj = Ext.getCmp('searchField');
searchFiledObj.setRawValue(s_psrName);
searchFiledObj.onTrigger2Click();






你可能感兴趣的:(Extjs SearchField 应用)