Feb 29, 2012, 9:49 AM
Delete rows depending on value with button
Hello, I need to delete some rows depending on the value of the columnStatus.
For example, I have 6 rows with values (1,1,3,2,4,3) and I want to delete rows with status 2,3 and 4 resulting in only two rows left, row 1 and row 2.
I tried some pseude code but don?t how to actually implement it. I prefer as much as possible code behind with C#.
For example, I have 6 rows with values (1,1,3,2,4,3) and I want to delete rows with status 2,3 and 4 resulting in only two rows left, row 1 and row 2.
ID Status
Row 1 1 1
Row 2 2 1
Row 3 3 3
Row 4 4 2
Row 5 5 4
Row 6 6 3
My panel with the delete button:<ext:Panel runat="server" ID="panel" Height="0">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button ID="btnClearSelection" runat="server" Text="Delete" OnDirectClick="btnClearSelection_Clicked"
Icon="Delete">
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
My gridpanel:<ext:GridPanel ID="grid" runat="server" Title= ?" AutoWidth="true" AutoHeight="true"
Padding="4" StripeRows="true" Draggable="false" Selectable="true" Icon="Application">
<Store>
<ext:Store ID="Store1" runat="server">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name=" personID " Mapping="PersonsId"/>
<ext:RecordField Name="description" Mapping="Description " />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column DataIndex="personID" Header="ID" Width="100">
</ext:Column>
<ext:Column ColumnID="columnStatus" DataIndex=" description " Header="Status" Width="130">
<Renderer Handler="return imgRenderer(value);" />
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="false"/>
</SelectionModel>
</ext:GridPanel>
Code behind.I tried some pseude code but don?t how to actually implement it. I prefer as much as possible code behind with C#.
protected void btnClearSelection_Clicked(Object sender, DirectEventArgs e)
{
// Get store
// Get rows
// Go through every row, if rows (columnstatus = 2,3 and 4) delete it
// Go the DB and also delete the records where columnstatus = 2,3 and 4
// reload store
}