Ext.fly和Ext.get差異在速度以及實際元素指向
fly比較快,但實際元素指向需要看前面程式碼是否有使用到別的元素

<html xmlns="https://www.w3.org/1999/xhtml">
<head>
    <title>Ext.get()/Ext.fly()區別</title>
<script type="text/javascript" src="shared/ext-base.js"></script>
<script type="text/javascript" src="shared/ext-all.js"></script>
<style type="text/css">
 body
 {
  padding:50px;
 }
 .error
 {
  color:Red;
 }
 #myElementId, #foo, #bar
 {
  width:300px;
  height:100px;
 }
</style>
</head>
<body>
<div id="myElementId">醉鄉路穩宜常至,他處不堪行</div>
<div id="foo">醉鄉路穩宜常至</div>
<div id="bar">他處不堪行</div>
<script type="text/javascript">
 Ext.fly('myElementId').removeClass('error');


 var el = Ext.fly('foo');
 Ext.fly('bar').frame();
 //Ext.fly('foo').frame();
 el.addClass('error'); //上面那行如果執行了 foo 會紅字


</script>
</body>
</html>


黒森林蛋糕 發表在 痞客邦 留言(0) 人氣()

 Ext.getDom('testDom')、 Ext.getDom(el)、 Ext.getDom(el.Dom)是一樣的都可取回testDom元素

<html xmlns="https://www.w3.org/1999/xhtml">
<head>
    <title>Ext Dom各種取法</title>
</head>
<script type="text/javascript" src="shared/ext-base.js"></script>
<script type="text/javascript" src="shared/ext-all.js"></script>
<body>
<div id="testDom">test</div>
<script type="text/javascript">
 alert(Ext.getDom('testDom') == document.getElementById('testDom')); //true表示同一個物件
 Ext.getDom('testDom'); //getDom可透過id取得物件回傳標準html元素
 var el = new Ext.Element('testDom'); //回傳Ext元素
 Ext.getDom(el); //將Ext.Element物件自動轉為標準html物件
 Ext.getDom(el.Dom); //直接傳回html物件
</script>
</body>
</html>


黒森林蛋糕 發表在 痞客邦 留言(0) 人氣()

最近有機會對倉庫系統專案做Code review,網頁的寫法大多是用ExtJs(其實是用ExtNet) 所以買了一本書學習一下:
 下面程式碼主要是用Ext.extend 將Person繼承Object之後寫簡單的方法和屬性,
再給另一個Developer繼承Person重寫已存在的方法,真是有物件導向的精神, 希望能夠學好ExtJs啊~
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
    <title>Ext中的繼承</title>
</head>
<script src="/shared/ext-base.js" type="text/javascript"></script>
<body>
<script type="text/javascript">
 Person = Ext.extend(Object, {
  constructor: function (first, last) {
   this.firstName = first;
   this.lastName = last;
  }
  , getName: function () {
         return this.firstName + ' ' + this.lastName;
        }
 });
 Developer = Ext.extend(Person, {
  isCoding: true,
  getName: function () {
   if (this.isCoding) {
    return '滾開';
   } else {
    return Developer.superclass.getName.call(this);
   }
  }
 });


    var p = new Person('John', 'Smith');
    alert('Hi, ' + p.getName());


    var d = new Developer('John', 'Smith');
    d.isCoding = false;
    alert('Hi, ' + d.getName());
</script>
</body>
</html>


 


黒森林蛋糕 發表在 痞客邦 留言(0) 人氣()

Strings
The only formatting available to Strings is the padding option, which can be positive or negative depending on whether the string should be left- or right-aligned:


String.Format("'{0,10}'", "John");


黒森林蛋糕 發表在 痞客邦 留言(0) 人氣()


ToolTip tips = new ToolTip();
tips.ToolTipTitle
= "lable提示";
tips.IsBalloon
= true;
tips.UseAnimation
= true;
tips.UseFading
= true;
tips.AutoPopDelay
= 3000;
tips.SetToolTip(
this.label1,"提示");

黒森林蛋糕 發表在 痞客邦 留言(0) 人氣()

1
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。