兩畝三分地

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            17 隨筆 :: 20 文章 :: 2 評論 :: 0 Trackbacks

          2009年10月29日 #

               摘要: 之前項目有個模塊要求用樹形解決,附帶要實現(xiàn)checkbox,增刪修改以及copy/cut/paste等等功能; 因為之前寫的人用了xloadTree,其他功能都實現(xiàn)了,但是客戶要求要有cookie功能,實現(xiàn)不了麻煩啊~ 正巧現(xiàn)在在學(xué)習(xí)用Ext,發(fā)現(xiàn)Ext的tree本身就很強大基本的功能都可以實現(xiàn)。 Code highlighting produced by Actipro Cod...  閱讀全文
          posted @ 2010-08-08 23:17 Chucky 閱讀(1963) | 評論 (0)編輯 收藏

          Border布局作為Ext中整個框架的布局應(yīng)該說很普遍,一般North放一個應(yīng)用的Logo bar,West一般會作為導(dǎo)航欄的放置位置;
          而Center(East)往往作為整個應(yīng)用的核心部分,而South位置也往往放置一些應(yīng)用的版權(quán)等信息。

          而導(dǎo)航欄一般會采用的呈現(xiàn)方式一般無非是Treepanel或者根據(jù)模塊放置多個Panel,而多數(shù)會采用的布局方式,往往是
          Accordion的布局。比如像這樣(偷個懶直接用設(shè)計器寫的):
          MyViewportUi = Ext.extend(Ext.Viewport, {
              layout: 'border',
              initComponent: 
          function() {
                  
          this.items = [
                      {
                          xtype: 'panel',
                          title: 'north',
                          region: 'north'
                      },
                      {
                          xtype: 'panel',
                          title: 'west',
                          region: 'west',
                          width: 
          201,
                          split: 
          true,
                          layout: 'accordion',
                          activeItem: 
          0,
                          items: [
                              {
                                  xtype: 'panel',
                                  title: 'panel1',
                                  layout: 'column',
                                  width: 
          180,
                                  items: [
                                      {
                                          xtype: 'button',
                                          text: 'Button1',
                                          scale: 'large'
                                      },
                                      {
                                          xtype: 'button',
                                          text: 'Button2',
                                          scale: 'large'
                                      },
                                      {
                                          xtype: 'button',
                                          text: 'Button3',
                                          scale: 'large'
                                      },
                                      {
                                          xtype: 'button',
                                          text: 'Button4',
                                          scale: 'large'
                                      },
                                      {
                                          xtype: 'button',
                                          text: 'Button5',
                                          scale: 'large'
                                      },
                                      {
                                          xtype: 'button',
                                          text: 'Button6',
                                          scale: 'large'
                                      }
                                  ]
                              },
                              {
                                  xtype: 'panel',
                                  title: 'panel2'
                              },
                              {
                                  xtype: 'panel',
                                  title: 'panel3'
                              }
                          ]
                      },
                      {
                          xtype: 'panel',
                          title: 'east',
                          region: 'center'
                      },
                      {
                          xtype: 'panel',
                          title: 'south',
                          region: 'south'
                      }
                  ];
                  MyViewportUi.superclass.initComponent.call(
          this);
              }
          });
          一個基本的框架就產(chǎn)生了,而問題也隨之而來。最主要的問題是IE和FF顯示不一樣。應(yīng)該說FF顯示很正常,按鍵根據(jù)導(dǎo)航欄的大小,改變每一行顯示的數(shù)量;
          而IE呢,在第一次導(dǎo)航欄寬帶變大的時候,一切正常;而當導(dǎo)航欄寬度縮小的時候,原來每行的按鍵數(shù)卻并不變。想想這Ext都3.2了,不會還有這么腦殘的bug吧;
          google了下,國內(nèi)似乎對這個問題也沒有什么討論的;于是直接去官網(wǎng)的論壇問。

          最初別人的提議是,更改westPanel的屬性
          layout: {
              type: 'accordion',
              autoWidth: 
          false
          }
          等于禁止westPanel的子欄目自動變化寬度,試了如果westPanel的子欄目只有一個工作正常,但是如果多個的話,又悲劇了~

          因為每次只有1個子欄目的寬度在變化,所以產(chǎn)生這個問題也不足為奇了。

          最后某個網(wǎng)友提供了一個自己寫的補丁,問題解決了。
          Ext.layout.AccordionPatch = Ext.extend(Ext.layout.Accordion, {
              
              inactiveItems: [],
          //ADDED

              
          // private
              onLayout : function(ct, target){//ADDED
                  Ext.layout.AccordionPatch.superclass.onLayout.call(this, ct, target);
                  
          if(this.autoWidth === false) {
                      
          for(var i = 0; i < this.inactiveItems.length; i++) {
                          
          var item = this.inactiveItems[i];
                          item.setSize(target.getStyleSize());
                      }
                  }
              },
              
          // private
              beforeExpand : function(p, anim){//MODFIED
                  var ai = this.activeItem;
                  
          if(ai){
                      
          if(this.sequence){
                          
          delete this.activeItem;
                          ai.collapse({callback:
          function(){
                              p.expand(anim 
          || true);
                          }, scope: 
          this});
                          
          return false;
                      }
          else{
                          ai.collapse(
          this.animate);
                          
          if(this.autoWidth === false && this.inactiveItems.indexOf(ai) == -1)//*****
                              this.inactiveItems.push(ai);//*****
                      }
                  }
                  
          this.activeItem = p;
                  
          if(this.activeOnTop){
                      p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);
                  }
                  
          if(this.autoWidth === false && this.inactiveItems.indexOf(this.activeItem) != -1)//*****
                      this.inactiveItems.remove(this.activeItem);//*****
                  this.layout();
              }
              
          });

          Ext.Container.LAYOUTS['accordionpatch'] 
          = Ext.layout.AccordionPatch; 
          配合補丁,westPanel的屬性也要有相應(yīng)的變化
          layout: {
              type:
          'accordionpatch',
              autoWidth: false
          }




          posted @ 2010-08-07 13:24 Chucky 閱讀(324) | 評論 (0)編輯 收藏

               摘要: 發(fā)表,瀏覽,回復(fù)之后,我們將討論的是刪除和編輯留言。 因為這個只是一個簡單的留言板,沒有用戶認證之類繁瑣的事情,所以對于編輯和刪除留言,必須輸入 正確的id號和password;如果在發(fā)表或回復(fù)留言的時候沒有輸入密碼的話,就不能對留言進行編輯或者刪除。 這里將寫的EditAction class與之前的有所不同,extends org.apache.struts.actions.Dispat...  閱讀全文
          posted @ 2009-10-29 17:22 Chucky 閱讀(243) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 澄城县| 恩平市| 安塞县| 蛟河市| 华池县| 冕宁县| 长宁区| 灵丘县| 城口县| 刚察县| 尼勒克县| 铜山县| 昆山市| 枣阳市| 广河县| 法库县| 阳谷县| 无为县| 海伦市| 尤溪县| 梅河口市| 疏勒县| 渝中区| 安宁市| 南部县| 夏津县| 兴隆县| 吴旗县| 腾冲县| 阿拉善右旗| 英山县| 广西| 连江县| 景洪市| 彰武县| 乐陵市| 廉江市| 西贡区| 香港 | 武宣县| 内江市|