先看上代码

<body>
    
<ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="X"
        IDMode
="Explicit" InitScriptMode="Linked" />
    
<form id="form1" runat="server">
    
<ext:Viewport runat="server" ID="vwpLayout" Layout="fit">
        
<Items>
            
<ext:GridPanel runat="server" ID="grdMain" Layout="fit" Border="false" AutoScroll="true" AutoHeight="false">
                
<TopBar>
                    
<ext:Toolbar runat="server">
                        
<Items>
                            
<ext:Button runat="server" ID="btnAdd" IconCls="add-css" Text="新 增">
                            
</ext:Button>
                            
<ext:Button runat="server" ID="btnSearch" IconCls="search-css" Text="查 询">
                            
</ext:Button>
                            
<ext:Button runat="server" ID="btnBatchDelete" IconCls="remove-css" Text="批量删除">
                            
</ext:Button>
                        
</Items>
                    
</ext:Toolbar>
                
</TopBar>
                
<SelectionModel>
                    
<ext:CheckboxSelectionModel runat="server" SingleSelect="false" Sortable="false">
                    
</ext:CheckboxSelectionModel>
                
</SelectionModel>
                
<LoadMask Msg="正在载入……" ShowMask="true" />
                
<ColumnModel DefaultSortable="true" runat="server" ID="colmMain">
                    
<Columns>
                        
<ext:RowNumbererColumn Align="Right" Resizable="false">
                        
</ext:RowNumbererColumn>
                        
<ext:NumberColumn Align="Left" DataIndex="FDegreeCode" Editable="false" Header="编 码"
                            Format
="0">
                        
</ext:NumberColumn>
                        
<ext:Column Align="Left" DataIndex="FDegreeName" Editable="false" Header="名 称">
                        
</ext:Column>
                    
</Columns>
                
</ColumnModel>
                
<Store>
                    
<ext:Store runat="server" ID="storeMain">
                        
<Reader>
                            
<ext:JsonReader IDProperty="FDegreeCode">
                                
<Fields>
                                    
<ext:RecordField Name="FDegreeCode" Type="Int">
                                    
</ext:RecordField>
                                    
<ext:RecordField Name="FDegreeName">
                                    
</ext:RecordField>
                                
</Fields>
                            
</ext:JsonReader>
                        
</Reader>
                    
</ext:Store>
                
</Store>
            
</ext:GridPanel>
        
</Items>    
    

<Listeners> <AfterLayout Handler="#{grdMain}.setHeight(#{vwpLayout}.getHeight());" /> </Listeners>
</ext:Viewport></form></body>

请注意文中红色加粗部分 

主要原理为在GridPanel 对象的父容器中添加AfterLayout监听事件,并在监听事件中重新设置GridPanel高度;

 GridPanel 的AutoHeight属性不能为true,否则代码将无效。


posted on 2010-11-10 15:22  地瓜他爸  阅读(3012)  评论(0编辑  收藏  举报