How to get values from the currently selected row within a Ext.Net.GridPanel outside of the SelectionModel?

Evils picture Evils · Oct 27, 2011 · Viewed 12.4k times · Source

I have the following code within my .aspx file

<ext:GridPanel
            runat="server"
            ID="GridPanel1"
            Height="450"
            Title="EmployeeList"
            Width = "850"
            Header = "false"
            StyleSpec = "margin: 25px;"
            StripeRows="true"
            TrackMouseOver="true"
            Border="true" ClicksToEdit="2">
            <Store>
                <ext:Store ID="Store1" runat="server" DataSourceID="LinqDataSource1">
                    <Reader>
                        <ext:JsonReader IDProperty="id" >
                            <Fields>
                                <ext:RecordField Name="id" />
                                <ext:RecordField Name="shortcode" />
                                <ext:RecordField Name="lastname" />
                                <ext:RecordField Name="firstname" />
                                <ext:RecordField Name="roomnumber" />
                                <ext:RecordField Name="landline" />
                                <ext:RecordField Name="mobile" />
                                <ext:RecordField Name="mail" />
                                <ext:RecordField Name="position" />
                                <ext:RecordField Name="department" />
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModel1" runat="server" >
                <Columns>
                    <ext:Column DataIndex="id" Header="Index" Width="50"/>
                    <ext:Column DataIndex="shortcode" Header="Kuerzel" Align="Center" />
                    <ext:Column DataIndex="lastname" Header="Nachname"   />
                    <ext:Column DataIndex="firstname" Header="Vorname"  />
                    <ext:Column DataIndex="roomnumber" Header="Raumnummer" Align="Center" Width="50"/>
                    <ext:Column DataIndex="landline" Header="Durchwahl intern" Align="Center" Width="50"/>
                    <ext:Column DataIndex="mobile" Header="Durchwahl handy"  Align="Center" Width="50"/>
                    <ext:Column DataIndex="mail" Header="Mail"  />
                    <ext:Column DataIndex="position" Header="Funktion"  />
                    <ext:Column DataIndex="department" Header="Abteilung"  />
                </Columns>
            </ColumnModel>  
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" SingleSelect="true">

<%--                   <Listeners> 
                        <RowSelect Handler="#{EditPanel}.getForm().loadRecord(record);" /> 
                    </Listeners>--%>

                    <DirectEvents>
                        <RowSelect OnEvent="SaveCurrentSelection">
                            <ExtraParams>
                                <ext:Parameter Name="usID" Value="this.getSelected().id" Mode="Raw" />
                            </ExtraParams>
                        </RowSelect>
                    </DirectEvents>
                </ext:RowSelectionModel> 
            </SelectionModel>   
        <KeyMap>
            <ext:KeyBinding Ctrl="true">
                <Keys>
                    <ext:Key Code="Y" />
                </Keys>
                <Listeners>
                    <Event Handler="#{DirectMethods}.ShowSearchWindow();" />
                </Listeners>
            </ext:KeyBinding>
        </KeyMap>
        <DirectEvents>
            <RowDblClick OnEvent="SwitchToUserDetail">
                <ExtraParams>
                    <ext:Parameter Name="id" Value="this.selModel.getSelected().id" Mode="Raw"></ext:Parameter>
                </ExtraParams>
            </RowDblClick>
        </DirectEvents>     

        </ext:GridPanel>

Now I need to get the id field of the currently selected row as how I get it within my RowSelect Listener

<ext:Parameter Name="usID" Value="this.getSelected().id" Mode="Raw" />

But this time not within the SelectionModel. I need to get it here:

<DirectEvents>
  <RowDblClick OnEvent="SwitchToUserDetail">
    <ExtraParams>
        <ext:Parameter Name="id" Value="this.selModel.getSelected().id" Mode="Raw"></ext:Parameter>
    </ExtraParams>
  </RowDblClick>
 </DirectEvents>

Outside of the SelectionModel but inside the GridPanel.

I think the way is to get it here:

Value = "this.selModel.getSelected().id"

I need to get that here as I don't want to do it inside the CodeBehind and as the Listener and DirectEvent does not work together in my SelectionModel

An answer will be appreciated

Answer

Baidaly picture Baidaly · Oct 29, 2011

You can access field of record like this

this.selModel.getSelected().data.shortcode