1、Ext面板中的工具栏
tbar里是按钮居右的符号是“->”,分隔符是“-”。
Ext.onReady(function(){
var panel = new Ext.Panel({
renderTo:"myPanel",
id : "testPanel",
autoWidth : true,
autoHeight : true,
autoScroll : true,
frame:false,
border : false,
margins : '0 0 0 0',
split : true,
minHeight : 100,
autoHeight : true,
tbar : [{
iconCls: 'icon-add',
text : '添加'
},{
iconCls: 'icon-remove',
text : '移除'
}]
});
panel.tbar.dom.align = 'center';
});
2、去除字符串空格,空格出现的位置分别为前中后,下面分别有两种方式处理
方式一(无法处理中间的空格)
str=str.replace(/(^\s*)|(\s*$)/g,"");
//replace(/(^\s*)/g, "") 去左空格
//replace(/(\s*$)/g, "") 去右空格
方式二(包括中间的空格)
function doTrim(str,is_global)
{
var result;
result = str.replace(/(^\s+)|(\s+$)/g,"");
if(is_global.toLowerCase()=="g")
result = result.replace(/\s/g,"");
return result;
}
3、屏蔽文本框的字符键(输入框只接受数字)
function checkNumb(){
if (event.keyCode < 45 || event.keyCode > 57)
event.returnValue = false;
}
4、javascript call函数的标准解释:call方法是将一个对象的方法在另一个对象的上下文环境中执行
5、管理端使用了富文本编辑器后将说明信息维护到数据库中,保存的字符串中当然包含了html标签。将数据取出保存到前台js对象中后,取得时候发现字符串中的html标签已经被转义掉了,显示到页面后又被解析回来显示成了html字符串,为了解决这一问题:
$("#xksm_text").html($("<div/>").html(top.xksz['xksm']).text());
//核心解决方法:$("<div/>").html(encodedStr).text();
6、截取字符串最后一位。
方法一:运用String对象下的charAt方法 str.charAt(str.length – 1)
方法二:运用String对象下的substr方法 str.substr(str.length-1,1)
方法三:运用String对象下的split方法 var str = “123456″; spstr = str.split(“”);spstr[spstr.length-1];
今天解决Ext一个小问题:
设置Ext中comboxBox下拉框的默认值,同事使用setValue结果下拉组件直接显示了value而不是displayValue;
解决方法是:
combo.store.on('load',function(store,records,opts){
Ext.each(records,function(rec){
if(rec.data.VALUE == 需要作为默认值的变量){
combo.setValue(?);//设置值
combo.setRawValue(?);//设置显示值
}
});
});