我的.aspx文件中有以下代码
<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>
现在我需要获取当前所选行的id字段,以便我在RowSelect Listener中获取它
<ext:Parameter Name="usID" Value="this.getSelected().id" Mode="Raw" />
但这次不在SelectionModel内。我需要在这里得到它:
<DirectEvents>
<RowDblClick OnEvent="SwitchToUserDetail">
<ExtraParams>
<ext:Parameter Name="id" Value="this.selModel.getSelected().id" Mode="Raw"></ext:Parameter>
</ExtraParams>
</RowDblClick>
</DirectEvents>
在SelectionModel之外但在GridPanel内部。
我认为方法是在这里:
Value = "this.selModel.getSelected().id"
我需要在这里得到它,因为我不想在CodeBehind中执行它,因为Listener和DirectEvent在我的SelectionModel中不能一起工作
答案将不胜感激
答案 0 :(得分:8)
您可以像这样访问记录字段
this.selModel.getSelected()。data.shortcode
答案 1 :(得分:1)
不幸的是,这对我不起作用:
App.GridPanel1.getSelectionModel()。getSelected()。data.Id
但是这个:
App.GridPanel1.getSelectionModel()。getSelected()。项[0] .data.Id
答案 2 :(得分:0)
在Ext.NET的更高版本中已经改变了。要获取行的IDProperty,请注意“getSelected()”现在是“getSelection()”,并且该函数返回所选对象的数组:
<SelectionModel>
<ext:RowSelectionModel runat="server">
<Listeners>
<Select Handler="#{GridPanel1}.selModel.getSelection()[0].internalId" />
</Listeners>
</ext:RowSelectionModel>
</SelectionModel>