//创建treeCombox.js
Ext.define('Redm.commons.TreeCombox', {
extend : 'Ext.form.field.Picker',
xtype : 'treecombox',
triggerCls : Ext.baseCSSPrefix + 'form-arrow-trigger',
config : {
displayField : null,
columns : null,
rootVisible : false,
selectOnTab : true,
firstSelected : false,
maxPickerWidth : 200,
maxPickerHeight : 360,
minPickerHeight : 50
},
editable : false,
initComponent : function() {
var me = this;
me.callParent(arguments);
this.addEvents('select');
me.store.on('load', me.onLoad, me);
},
createPicker : function() {
var me = this, picker = Ext.create('Ext.tree.Panel', {
id : 'treePicker',
store : me.store,
floating : true,
hidden : true,
width : me.maxPickerWidth,
displayField : me.displayField,
columns : me.columns,
maxHeight : me.maxTreeHeight,
shadow : false,
rootVisible : me.rootVisible,
manageHeight : false,
listeners : {
itemclick : Ext.bind(me.onItemClick, me)
},
viewConfig : {
listeners : {
render : function(view) {
view.getEl().on('keypress', me.onPickerKeypress, me);
}
}
}
}), view = picker.getView();
view.on('render', me.setPickerViewStyles, me);
if (Ext.isIE9 && Ext.isStrict) {
view.on('highlightitem', me.repaintPickerView, me);
view.on('unhighlightitem', me.repaintPickerView, me);
view.on('afteritemexpand', me.repaintPickerView, me);
view.on('afteritemcollapse', me.repaintPickerView, me);
}
return picker;
},
setPickerViewStyles : function(view) {
view.getEl().setStyle({
'min-height' : this.minPickerHeight + 'px',
'max-height' : this.maxPickerHeight + 'px'
});
},
repaintPickerView : function() {
var style = this.picker.getView().getEl().dom.style;
style.display = style.display;
},
alignPicker : function() {
var me = this, picker;
if (me.isExpanded) {
picker = me.getPicker();
if (me.matchFieldWidth) {
picker.setWidth(this.picker.getWidth());
}
if (picker.isFloating()) {
me.doAlign();
}
}
},
onItemClick : function(view, record, node, rowIndex, e) {
this.selectItem(record);
},
onPickerKeypress : function(e, el) {
var key = e.getKey();
if (key === e.ENTER || (key === e.TAB && this.selectOnTab)) {
this.selectItem(this.picker.getSelectionModel().getSelection()[0]);
}
},
selectItem : function(record) {
var me = this;
me.setValue(record.get(this.valueField));
me.picker.hide();
me.inputEl.focus();
me.fireEvent('select', me, record);
me.collapse();
},
onExpand : function() {
var me = this, picker = me.picker, store = picker.store, value = me.value;
if (value) {
var node = this.picker.getSelectionModel().getSelection()[0];
if (node)
picker.selectPath(node.getPath());
} else {
var hasOwnProp = me.store.hasOwnProperty('getRootNode');
if (hasOwnProp)
picker.getSelectionModel().select(store.getRootNode());
}
Ext.defer(function() {
picker.getView().focus();
}, 1);
// 全展开
picker.expandAll();
},
setValue : function(value) {
var me = this, record;
me.value = value;
if (me.store.loading) {
return me;
}
try {
var hasOwnProp = me.store.hasOwnProperty('getRootNode');
var recordStore = this.picker.getSelectionModel().getSelection()[0];
record = value ? recordStore : (hasOwnProp ? me.store.getRootNode() : null);
me.setRawValue(record ? record.get(this.displayField) : '');
} catch (e) {
me.setRawValue('');
}
return me;
},
getValue : function() {
return this.value;
},
onLoad : function(store, node, records) {
if (this.firstSelected) {
if (records && records.length > 0) {
var record = records[0];
this.setValue(record.get(this.valueField));
this.setRawValue(record.get(this.displayField));
}
}
//var value = this.value;
console.log(value);
//if (value) {
//this.setValue(value);
//} else {
//if (this.firstSelected) {
//if (records && records.length > 0) {
//var record = records[0];
//this.setValue(record.get(this.valueField));
//this.setRawValue(record.get(this.displayField));
//}
//}
//}
},
getSubmitData : function() {
var me = this, data = null;
if (!me.disabled && me.submitValue) {
data = {};
data[me.getName()] = '' + me.getValue();
}
return data;
},
onTriggerClick : function() {
var me = this;
// me.store.load();
if (!me.readOnly && !me.disabled) {
if (me.isExpanded) {
me.collapse();
} else {
me.expand();
}
me.inputEl.focus();
}
}
});
//获取某一个cookie的值 const getCookie = key => {var k = key, dc = document.cookie;if (dc.length > 0) {var s = dc.indexOf(k + "=");if (s != -1) {s = s + k.length + 1;var e = d...
var SGheadMapPoints = {/*obj={ maxLng: minLng: maxLat: minLat: maxCount:最大人数 minCount:最小人数 total:点位数量 }*/get: function (obj) {var arr = [];obj.maxCount || (obj.maxCount...
创建index.html代码如下
//自动搜索指定的请柬 var alertTipText = "请柬找到了,就在这个网页里面,自己仔细看吧"; var delay = 1 * 1000;//1秒后循环下一页寻找 /*获取子DOM元素在父元素里面的索引位置(是第几个元素)*/ function getNodeListIndex(childNode) {return c...
获取天气情况(不支持跨域) /*json原生获取*/ function getJSON() {var XML;var url = "http://wthrcdn.etouch.cn/weather_mini?city=杭州";if (window.XMLHttpRequest) {XML = new XMLHttpRequest(...
#include
题目:表示数值的字符串 请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。例如,字符串"+100"、"5e2"、"-123"、"3.1416"、"0123"及"-1E-16"都表示数值,但"12e"、"1a3.14"、"1.2.3"、"+-5"及"12e+5.4"都不是。 解题: 数值错误的形式有多种多样,但是正确的...
加法伺候 //超过20位数值相加---------------------------------------- function bigNumAdd(a, b) {if (!(typeof a === "string" && typeof b === "string")) return console.log("传入参数必...
业务场景: 从中文字句中匹配出指定的中文子字符串 .这样的情况我在工作中遇到非常多, 特梳理总结如下. 难点: 处理GBK和utf8之类的字符编码, 同时正则匹配Pattern中包含汉字,要汉字正常发挥作用,必须非常谨慎.推荐最好统一为utf8编码,如果不是这种最优情况,也有酌情处理. 往往一个具有普适性的正则表达式会简化程...
简单record 一下
#include