2016-11-25 4 views
0

ExtJS 3.4、height:200でGridPanelを作った。時々高さを変える必要があります。setHeightの後にExtJSグリッドがリフレッシュされない

setHeight(65)を短くしてからsetHeightを元の高さ:200に戻すと、グリッドは境界線が200の高さに戻りますが、内側の内容は外観に残ります私はsetHeightメソッドの後に以下しようとした65 の高さ、ない運:

 grid.setHeight(200); 
    //myStore.load(); 
    //myStore.reload(); 
    //myStore.getStore().load(); 
    //grid.render(); 
    //grid.getView().refresh(); 
    //grid.getView().refresh(true); 
    //grid.getView().updateLayout(); 
    //grid.doLayout(); //just tried not okay 

the grid won't refresh

//the code: 
 
    grid = new Ext.grid.GridPanel({ 
 
     id: "myGrid", 
 
     store: myStore, 
 
     selModel: mySelectionModel, 
 
     columns: [ 
 
      mySelectionModel, 
 
      { 
 
       id: 'name', 
 
       header: "Item", 
 
       width: 240, 
 
       menuDisabled: true, 
 
       dataIndex: 'name' 
 
      } 
 
     ], 
 
     height: 200, 
 
     width: 280, 
 
     listeners: { 
 
      "keydown": function (e) { 
 
       if (e.getKey() == 17) { 
 
        mySelectionModel.clearSelections(); 
 
       } 
 
      } 
 
     } 
 
    }); 
 
//another item on top of the gird enlarged code here, so shorter the grid: 
 
grid.setHeight(65) 
 
//the item on top returned to be smaller code here 
 
//so then I return the height of the grid to its original in the line below: 
 
grid.setHeight(200); 
 
//however, after the above line, the content remains as the height of 65

+0

簡単なフィドルを追加できますか? –

+0

または単にコードを追加しますか?グリッドとは何ですか?グリッドまたはグリッドビュー? –

答えて

-1

新しい幅を設定した後にこれを試してください grid.doLayout();

Try the below fiddle 

jsfiddle.net/praveensov/7kpZ9/737 これは、高さ

+0

うまく動作しません>。< – Todayboy

+0

http://jsfiddle.net/praveensov/7kpZ9/736/試してください –

+0

http://jsfiddle.net/praveensov/7kpZ9/737/これは設定高さが –

0

奇妙な設定をいじるに更新されます。私はコードを単純化しようとしましたが、高さを変更してもグリッドのコンテンツの高さは正しく設定されています。あなたの親コンテナはどのレイアウトですか?

例(https://fiddle.sencha.com/#view/editor&fiddle/1l7c):

Ext.onReady(function() {  
    var grid = new Ext.grid.GridPanel({  
    title: 'People',  
    renderTo: Ext.getBody(),  
    store: new Ext.data.JsonStore({  
     fields: [ 'id', 'name' ],  
     data: [  
     { id: 1, name: 'Jack' },  
     { id: 2, name: 'Brian' },  
     { id: 3, name: 'John' },  
     { id: 4, name: 'James' },  
     { id: 5, name: 'Anna' },  
     { id: 6, name: 'Dorothy' },  
     { id: 7, name: 'Mike' },  
     { id: 8, name: 'Daisy' },  
     { id: 9, name: 'Brian' },  
     { id: 10, name: 'Brian' }  
     ]  
    }),  
    columns: [  
     { header: "Id", width: 50, menuDisabled: true, dataIndex: 'id' },  
     { header: "Name", width: 150, menuDisabled: true, dataIndex: 'name' }  
    ],  
    height: 200,  
    width: 280  
    });  

    grid.setHeight(60);  
    grid.setHeight(200);  
    grid.setHeight(90);  
    grid.setHeight(150);  
}); 
+0

のフィドルですもし、高さと短さを一緒に設定して同じテーブルを返しても、私のコードでは、すべてのアイテムを拡大する機能と、すべてのアイテムを短くする機能があります。グリッドはExt.panelの中​​にあります。理由は分かりません。私のコードを簡素化し、より多くのフィドルを提供しようとします。 – Todayboy

0

私は最終的に行う方法を考え出しました!努力してくれてありがとう。申し訳ありませんがコードがあまりにも多いので、私は最初に詳しく述べませんでした。 girdはExt.TabPanelの3番目のタブの内側にあり、実際にはすべてのアイテムを通常の状態に戻したいときは、最初のタブに戻ります。 私がする必要があるのは以下のとおりです:

myContainer = new Ext.TabPanel({ 
//other properties of TabPanel 
    listeners: { 
    "tabchange": function (tabpanel, tab) { 
    if (tab.tabid == 3) { //the tab where the grid are 
     grid.getView().refresh(); 
    } 
}) 
関連する問題