ExtJS4.2 常用技巧 (不断更新)

去除字符串两边的空格:

var hello = Ext.String.trim('  hello  ');


grid, cellediting, textfield :

回车时过滤/删除不符合条件的数据:

                    ptype: 'cellediting',
                    clicksToEdit: 2,
                    listeners: {
                        edit: function(editor, e){
                            var expression = e.record.get('expression');
                            expression = Ext.String.trim(expression);
                            if ("" == expression){
                            	return ;
                            }
                            
                            var reg = /^\d+([.]\d+){0,1}$/;
                            if (!reg.test(expression)){
                            	Ext.Msg.alert('提示', '格式错误! (样例: 0.35)');
                            	e.record.reject();
                            	return false;
                            }
                            
                            
                        }
                    }


你可能感兴趣的:(ExtJs)