PDA

View Full Version : Selection Row With Grid Command(!)



ismailkocacan
Jun 12, 2012, 2:09 PM
Hi ;
Question : How can I select row when grid command button clicked ?
Answer :



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body oncontextmenu="return false;">
<form id="form1" runat="server">
<ext:ResourceManager ID="ResMan" runat="server" />
<ext:Store ID="storeCustomer" runat="server">
<Reader>
<ext:JsonReader IDProperty="ID">
<Fields>
<ext:RecordField Name="ID" Type="Int" />
<ext:RecordField Name="FirstName" Type="String" />
<ext:RecordField Name="LastName" Type="String" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>

<ext:Viewport ID="viewPort" runat="server" Layout="Fit">
<Items>
<ext:GridPanel ID="grdCustomer" Frame="false" runat="server" AutoWidth="true" Height="275"
Icon="Application" StoreID="storeCustomer" Border="true">

<ColumnModel ID="columnModel" runat="server">
<Columns>
<ext:Column DataIndex="ID" Header="ID" Width="65">
</ext:Column>
<ext:Column DataIndex="FirstName" Header="FirstName" Width="200">
</ext:Column>
<ext:Column DataIndex="LastName" Header="LastName">
</ext:Column>

<ext:CommandColumn Width="60">
<Commands>
<ext:GridCommand Icon="Delete" CommandName="cmdDelete" StandOut="true">
<ToolTip Text="Delete" />
</ext:GridCommand>
<ext:CommandSeparator />
<ext:GridCommand Icon="ApplicationFormEdit" CommandName="cmdEdit" StandOut="true">
<ToolTip Text="Edit" />
</ext:GridCommand>
</Commands>
</ext:CommandColumn>
</Columns>
</ColumnModel>
<LoadMask ShowMask="true" />
<Plugins>
<ext:GridFilters runat="server" ID="gridFilter" Local="true" FiltersText="Filtre Uygula">
<Filters>
<ext:StringFilter DataIndex="ID" />
<ext:StringFilter DataIndex="FirstName" />
<ext:StringFilter DataIndex="LastName" />
</Filters>
</ext:GridFilters>
</Plugins>
<SelectionModel>
<ext:RowSelectionModel runat="server" ID="rowSelModel" SingleSelect="true">
</ext:RowSelectionModel>
</SelectionModel>
<View>
<ext:GridView EmptyText="G??tlenebilecek kayt bulunamad.">
</ext:GridView>
</View>
<Listeners>
<Command Handler="#{rowSelModel}.selectRow(rowIndex); if (command=='cmdDelete') { return; }" />
</Listeners>
<DirectEvents>
<Command OnEvent="gridCommmandHandler">
<ExtraParams>
<ext:Parameter Name="Values" Value="Ext.encode(#{grdCustomers}.getRowsValues({selected Only : true}))"
Mode="Raw" />
<ext:Parameter Name="cmd" Value="command" Mode="Raw" />
<ext:Parameter Name="index" Value="rowIndex" Mode="Raw" />
</ExtraParams>
</Command>
</DirectEvents>
<BottomBar>
<ext:PagingToolbar ID="pagingToolbar" runat="server" PageSize="20" StoreID="storeCustomer">
</ext:PagingToolbar>
</BottomBar>
</ext:GridPanel>
</Items>
</ext:Viewport>
</form>
</body>
</html>





<Command Handler="#{rowSelModel}.selectRow(rowIndex); if (command=='cmdDelete') { return; }" />


By İsmail Kocacan

peter.campbell
Jun 14, 2012, 10:15 AM
On the commands Before handler:



this.getSelectionModel().selectById(record.id)