2011-01-25 32 views
1

我有一個Ext.Grid.EditorGridPanel問題,我目前正在使用ExtJS 2.3.0,無法更改。 :-(ExtJS EditorGridPanel顯示錯誤

以下問題:

我創建了包括2個FormPanel中和它們之間的EditorGridPanel窗口 網格的viewConfig,只有「forceFit = TRUE」設置,或沒有風格或查看爲ColumnModel設置的選項 僅針對每個列的align選項設置爲「center」 ColumnModel由13列組成,只有更多或更少的文本 現在我打開我正在使用瀏覽器並打開窗口來測試GUI 當我嘗試在單行中的單元格之間切換時,整個數據行向左移動 ,以便第一個單元格a不再顯示。 向網格添加新行(通過添加按鈕)後,視圖將重置,並且每個列的所有單元格都會再次正確顯示。 列標題和tbar是固定的並始終正確呈現。

該問題發生在IExplorer 8.0x,一個較老的Firefox版本(2.0x),但網格在Firefox 3.6x和Safari 5.0x下正常工作。 如果有人有類似的問題,並得到解決或想法可能導致這個問題,隨時回答。 ;-) 非常感謝提前!

[編輯] THX徵求意見,從完整的源在這裏一些modifyed來源:

所有的
getTypeSelectionGrid: function() { 
    this.gridRecord: Ext.data.Record.create([ 
     {name:'id', type:'int'}, 
     {name:'start', type:'string'}, 
     {name:'end', type:'string'}, 
     {name:'mo', type:'boolean'}, 
     {name:'tu', type:'boolean'}, 
     {name:'we', type:'boolean'}, 
     {name:'th', type:'boolean'}, 
     {name:'fr', type:'boolean'}, 
     {name:'sa', type:'boolean'}, 
     {name:'su', type:'boolean'}, 
     {name:'type', type:'string'} 
    ]); 

    this.gridStore = new Ext.data.Store({ 
     baseParams: { 
     }, 
     sortInfo: {field: 'id', direction: 'ASC'}, 
     proxy: new Ext.data.HttpProxy({ 
      url: '', 
      method: 'post' 
     }), 
     reader: new Ext.data.JsonReader({ 
      root: 'data', 
      totalProperty: 'totalCount', 
      id: 'id' 
     }, this.gridRecord) 
    }); 

    var sm = new Ext.grid.RowSelectionModel({ singleSelect: true }); 

    var columnConfig = []; 
    //auto incremented id column 
    columnConfig.push({ 
     header: 'id', 
     dataIndex: 'id', 
     width: 50, 
     editor: new Ext.form.TextField({ 
      anchor: '100%', 
      allowBlank: false, 
      disabled: true 
     }) 
    }); 
    //start value for time range, values from '00:00' to '24:00' steps by second, here shorted to 2 options 
    columnConfig.push({ 
     header: 'start', 
     dataIndex: 'start', 
     width: 70, 
     align: 'center', 
     editor: new Ext.form.ComboBox({ 
      store: new Ext.data.SimpleStore({ 
       fields: ['val', 'txt'], 
       data : [['00:00', '00:00'],['24:00', '24:00']] 
      }), 
      displayField: 'txt', 
      valueField: 'val', 
      typeAhead: true, 
      mode: 'local', 
      triggerAction: 'all', 
      selectOnFocus: true, 
      saveRouting: true, 
      forceSelection: true, 
      anchor: '100%', 
      allowBlank: false 
     }) 
    }); 
    //same as above for end of time range, dataIndex 'end' 

    //now 7 checkbox columns foreach weekday 
    columnConfig.push({ 
     xtype: 'checkcolumn', 
     header: 'mo', 
     dataIndex: 'mo', 
     align: 'center', 
     width: 30 
    })); 
    //same as above for dataIndex 'tu', 'we', 'th', 'fr', 'sa' and 'su' 

    //here simplified to SimpleStore, originally a remote store which gets the data 
    //by a HttpProxy 
    columnConfig.push({ 
     header: 'type', 
     dataIndex: 'type', 
     editor: new Ext.form.ComboBox({ 
      store: new Ext.data.SimpleStore({ 
       fields: ['val', 'txt'], 
       data : [[1, 'type 1'],[2, 'type 2']] 
      }), 
      displayField: 'txt', 
      valueField: 'txt', 
      typeAhead: true, 
      mode: 'local', 
      triggerAction: 'all', 
      selectOnFocus: true, 
      saveRouting: true, 
      forceSelection: true, 
      anchor: '100%', 
      allowBlank: false 
     }) 
    }); 
    //then 2 plugins which have some functionality for the selected row 
    //grid tested with and without both plugins, they are not the cause 

    var cm = new Ext.grid.ColumnModel(columnConfig); 
    cm.defaultSortable = false; 

    //now the grid 
    this.typeSelectionGrid = new Ext.grid.EditorGridPanel({ 
     store: this.gridStore, 
     clicksToEdit: 1, 
     autoHeight: true, 
     cm: cm, 
     sm: sm, 
     viewConfig: { 
      forceFit: true 
     }, 
     tbar: [{ 
      text: 'add new row', 
      cls: 'x-btn-text', 
      scope: this, 
      handler: function(){ 
       //adds a row with incremented id 
      } 
     }], 
     listeners: { 
      scope: this, 
      show: function() { 
       sm.selectFirstRow.defer(1000, selectionModel); 
      } 
     } 
    }); 

    return this.typeSelectionGrid; 
}, 

//the grid is then inserted between the Panels into the window component 
//looks something like that 
render: function() { 

    var layoutFn = function(pnl) { 
     pnl.ownerCt.ownerCt.doLayout.defer(Ext.isIE ? 300 : 0, pnl.ownerCt.ownerCt); 
     pnl.doLayout.defer(Ext.isIE ? 500 : 200, pnl); 
    }; 
    this.cardLayout.add({ 
     layout: 'border', 
     border: false, 
     bodyStyle: 'background-color: #fff', 
     items: [ 
      { 
       region: 'center', 
       border: false, 
       layout: 'column', 
       autoScroll: true, 
       defaults: { 
        columnWidth: 1, 
        bodyStyle: 'padding: 5px;', 
        border: false, 
        autoHeight: true, 
        layout: 'column', 
        defaults: { 
         columnWidth: 1 
        } 
       }, 
       items: [ 
        //first Ext.form.FormPanel with some TextFields 
        { 
         items: { 
          listeners: { 
           expand: layoutFn, 
           collapse: layoutFn 
          }, 
          frame: true, 
          title: 'panel with a grid', 
          collapsible: true, 
          titleCollapse: true, 
          layout: 'fit', 
          autoHeight: true, 
          items: this.getTypeSelectionGrid() 
         } 
        } 
        //second Ext.form.FormPanel with some TextFields 
       ] 
      } 
     ] 
    }); 
} 
+0

如果你可以發佈示例代碼,它將是很好的調試:)乾杯 – 2011-01-25 14:44:57

回答

2

首先,它看起來像你有一些JavaScript語法錯誤。我知道你只發布了一段代碼,但試着通過JS Lint運行整個事情。

對於初學者:

this.gridRecord: Ext.data.Record.create([ 
    {name:'id', type:'int'}, 
    {name:'start', type:'string'}, 
    {name:'end', type:'string'}, 
    {name:'mo', type:'boolean'}, 
    {name:'tu', type:'boolean'}, 
    {name:'we', type:'boolean'}, 
    {name:'th', type:'boolean'}, 
    {name:'fr', type:'boolean'}, 
    {name:'sa', type:'boolean'}, 
    {name:'su', type:'boolean'}, 
    {name:'type', type:'string'} 
]); 

應該是:

this.gridRecord = Ext.data.Record.create([ 

雖然我不能完全肯定這會導致問題,我看到你的列CONFIGS分配有寬度。即使您正在設置viewConfig屬性「forceFit:true」,我懷疑編輯器可能會嘗試使用您爲每列設置的寬度。

看看是否清除任何東西。

0

謝謝,但代碼片段有複製和粘貼錯誤,gridRecord是原始代碼的全局屬性。 我忽略了,因爲我修改了代碼,對於混淆抱歉。

現在,我想你的建議,發現罪魁禍首: 好像IE無法處理「forceFit」選項可言,我評論了該選項,然後 設置寬度爲每列和...它的工作好,沒有列移動! 不,我插入一個工作,首先我檢查瀏覽器是否是一個IE瀏覽器,如果不是「forceFit」選項設置爲「true」else「false」。

非常感謝您的幫助!