兩畝三分地

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

          2010年8月7日 #

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

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

          而導(dǎo)航欄一般會采用的呈現(xiàn)方式一般無非是Treepanel或者根據(jù)模塊放置多個(gè)Panel,而多數(shù)會采用的布局方式,往往是
          Accordion的布局。比如像這樣(偷個(gè)懶直接用設(shè)計(jì)器寫的):
          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);
              }
          });
          一個(gè)基本的框架就產(chǎn)生了,而問題也隨之而來。最主要的問題是IE和FF顯示不一樣。應(yīng)該說FF顯示很正常,按鍵根據(jù)導(dǎo)航欄的大小,改變每一行顯示的數(shù)量;
          而IE呢,在第一次導(dǎo)航欄寬帶變大的時(shí)候,一切正常;而當(dāng)導(dǎo)航欄寬度縮小的時(shí)候,原來每行的按鍵數(shù)卻并不變。想想這Ext都3.2了,不會還有這么腦殘的bug吧;
          google了下,國內(nèi)似乎對這個(gè)問題也沒有什么討論的;于是直接去官網(wǎng)的論壇問。

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

          因?yàn)槊看沃挥?個(gè)子欄目的寬度在變化,所以產(chǎn)生這個(gè)問題也不足為奇了。

          最后某個(gè)網(wǎng)友提供了一個(gè)自己寫的補(bǔ)丁,問題解決了。
          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; 
          配合補(bǔ)丁,westPanel的屬性也要有相應(yīng)的變化
          layout: {
              type:
          'accordionpatch',
              autoWidth: false
          }




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

          主站蜘蛛池模板: 西昌市| 墨竹工卡县| 侯马市| 横山县| 巩义市| 绥滨县| 突泉县| 吉木乃县| 乌兰县| 蒲城县| 监利县| 神木县| 台北县| 长乐市| 昌黎县| 平和县| 西昌市| 安塞县| 定西市| 新营市| 应用必备| 蒙阴县| 临颍县| 神木县| 岳池县| 大厂| 雅安市| 聊城市| 阿城市| 满洲里市| 拜城县| 吉木乃县| 雅安市| 绍兴县| 保定市| 平武县| 盐山县| 普格县| 锡林浩特市| 三河市| 江西省|