Extjs3常用基础方法使用详解

 

/**
 * Extjs3.4常用基础方法使用
 */

Ext.onReady(function(){
/*var colorsArray=new Array();
colorsArray[0]='Blue';
colorsArray[1]='Red';
colorsArray[2]='White';


var colorsArrayType=Ext.type(colorsArray);
// colorsArrayType’s value is “array”.
document.writeln(colorsArrayType);

var isArray=Ext.isArray(colorsArray);
//isArray is true
document.writeln(isArray);

//position is 2, the index of 'White' in the array.
var position=colorsArray.indexOf('White');
document.write(position+"<br>");

 // 'Brown' does not exist in the array,
            // position is -1.  不存在返回-1,存在返回索引值
position=colorsArray.indexOf('Brown');
document.write(position+"<br>");
//remove one from a array
colorsArray.remove('Blue');
position=colorsArray.indexOf('Blue');
   // 'Blue' does not exist anymore,
            // position is -1.
document.write(position+"<br>");

var colorsObject={color1:'Blue',color2:'Red',color3: 'White'};

var colorsObjectType=Ext.type(colorsObject);
document.write(colorsObjectType);//colorsObjectType's value is "Ojbect"

var aNumber=1;
var aString='1';
//Ext.num:验证某个值是否数字的一个辅助方法,若不是,返回指定的缺省值
// number is 1.
var number=Ext.num(aNumber,0);
document.write(number);
//不是数字,返回指定默认值
number=Ext.num(aString,0);
document.writeln(number);

//converting empty references to a default value;
//验证值是否非空、非null、非undefined、非空白字符的便捷方法
var empty;
var notEmpty=Ext.value(empty,'defaultValue',false);
notEmpty is 'defaultValue'
document.writeln(notEmpty);


var sample;
var defined=Ext.util.Format.undef(sample+'define is an empty string<br/>');
document.write(defined);

  // defined is now "sample is now defined".
 sample = "sample is now defined";
  defined = Ext.util.Format.undef(sample);
   document.write(defined + '<br/>');*/
 /*
  var needsEscape = "ExtJS's String Class will escape this";
  //escape方法对‘进行转移为\'
  var escaped = String.escape(needsEscape);
  document.write(escaped+'<br>');
 
  var sort='ASC';
  sort=sort.toggle('ASC','DESC');
   document.write(sort);
  
   var sample = "some text";
   var converted=Ext.util.Format.uppercase(sample);
   // converted is now "SOME TEXT".
   document.write(converted+'<br>');
   sample = "SOME TEXT";
   converted=Ext.util.Format.lowercase(sample);
    document.write(converted+'<br>');*/
 
 
 var number1 = 20;
    var number2 = 72;
    //constrain输出在木个范围的值,就输出最小值或最大值
  var constrained = number1.constrain(25, 50);
  document.write(constrained+"<br>");
   var constraineds = number2.constrain(25, 50);
  
     document.write(constraineds+"<br>");
}
);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值