ExtJs的treelist中selectionchange默认选中一个
适用于treelist获取默认选中第一个子节点
该解决方案适用于树面板,但此处使用树列表。解决方案 将Ext.list.Tree组件设置为活动状态
listeners: {
//默认选中第一个子节点
painted: function (treelistEl) {
var treelist = treelistEl.component;
//这里设置一个选中状态,触发下面的selectionchange
treelist.setSelection(treelist.getStore().getRoot().firstChild);
},
selectionchange: function (treelist, record) {
.....
}
},
如何默认选中树(treeview)的节点
获取grid表格的某一条数据时,也可以用这个
listeners:{
//页面渲染之后
afterrender:function(){
var record = this.getStore().getNodeById(id);
this.getSelectionModel().select(record)
}
}
限制数字输入框的输入长度
#为什么我加了maxLength限制了长度 输入框还能输进去超过我限制的长度?
先看一下官方文档对maxLength的解释
Maximum input field length allowed by validation. This behavior is intended to provide instant feedback to the user by improving usability to allow pasting and editing or overtyping and back tracking.
To restrict the maximum number of characters that can be entered into the field use the enforceMaxLength option.
Defaults to Number.MAX_VALUE.
Defaults to:
Number.MAX_VALUE
翻译过来就是:
验证允许的最大输入字段长度。此行为旨在通过改进可用性向用户提供即时反馈,以允许粘贴和编辑或过度键入和回溯。
要限制可输入字段的最大字符数,请使用enforceMaxLength选项。
默认为Number.MAX\u值。
默认为:
最大值
问题就出在这 use the enforceMaxLength option.
我使用maxlength是需要一个开关的,开关就是这个enforceMaxLength 默认是false
所以我只写一个maxLength:6,是不行的,还得再加一个enforceMaxLength:true
所以 以后看官方文档时一定要认真看,我就是没认真看,Ext有部分是搭配使用,这个一定要注意。
enforceMaxLength和maxLength搭配使用
xtype: 'numberfield',
padding: '10px 10px 10px 20px',
enforceMaxLength:true,
maxLength: 6,
minValue: 0,
maxValue: 999999,
anchor: '70%',
allowDecimals: false, //是否允许小数
hideTrigger: true, //隐藏触发器
keyNavEnabled: false, //导航键已启用
mouseWheelEnabled: false, //鼠标滚轮已启用
minText :'输入大小必须在0-999999之间',
maxText: '输入大小必须在0-999999之间',
negativeText:'输入大小必须在0-999999之间',
fieldLabel: '大小策略(M)'