Oct 05, 2011, 9:20 AM
[CLOSED] GridPanel: Problem with Selecting First Row after loading (DirectEvent timing issue)
I have a Grid inside a Window (winTrendingPreferredList) which is initially Hidden=true. When a button is clicked, this window will be shown.
My goal is that when a button is clicked, it will go to code behind via DirectMethod, which will construct the grid (and the store with it), then show the window. Once shown, I want to select and highlight the first row.
I attached the Event in the grid's AfterLayout but it seems that the grid is empty when this is invoked, which causes an error. Can you advice which is the last event that will be triggered?
Javascript
My goal is that when a button is clicked, it will go to code behind via DirectMethod, which will construct the grid (and the store with it), then show the window. Once shown, I want to select and highlight the first row.
I attached the Event in the grid's AfterLayout but it seems that the grid is empty when this is invoked, which causes an error. Can you advice which is the last event that will be triggered?
Javascript
var TPLManager_FirstLoad = function(){
alert('FirstLoad');
var grid = Ext.getCmp('GridPanel1');
grid.getSelectionModel().selectRow(1);
grid.getView().focusRow(1);
}
<ext:GridPanel ID="GridPanel1" runat="server" Cls="without-dirty" EnableHdMenu="false"
StripeRows="false" HideHeaders="false" Height="180" ButtonAlign="Left" AutoExpandColumn="Name">
<Store>
<ext:Store ID="Store1" runat="server" WarningOnDirty="false" >
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="OID" Type="Int" />
<ext:RecordField Name="Name" Type="String" />
<ext:RecordField Name="SharingTypeOID" Type="Int" />
<ext:RecordField Name="TemplateName" Type="String" />
<ext:RecordField Name="ChkBox" Type="Boolean" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column Header="Preferred Group Name" DataIndex="Name" Resizable="false" Width="520" />
<ext:Column Header="Template Type" DataIndex="TemplateName" Resizable="false" Width="100" />
<ext:CheckColumn DataIndex="ChkBox" Editable="true" Resizable="false" Width="30" Sortable="false" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
</ext:RowSelectionModel>
</SelectionModel>
<Listeners>
<AfterLayout Handler="if(#{winTrendingPreferredList}.hidden == false) TPLManager_FirstLoad();" />
</Listeners>
</ext:GridPanel>
Regards, J
Last edited by Daniil; Oct 06, 2011 at 8:02 AM.
Reason: [CLOSED]