要求:我实现了一个功能,该功能通过根据值单击网格中的按钮来删除行。我的要求是从网格中删除状态为“Verwerkt”、“Ter Fiattering”、“Al verwerkt”的行,并在代码隐藏中添加一个方法,该方法也从数据库中删除记录。
问题:行已从网格中删除,但它们会在一/两秒后返回。真的很奇怪。我收到有关warningondirrty 的警告,但我已通过在商店中将其关闭来取消该消息(WarningOnDirty = false)。帮助 :)
网格面板:
<ext:Panel runat="server" ID="panel" Height="0">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button ID="btnHaalBatch" runat="server" Text="GBA synchroniseren" OnDirectClick="btnHaalBatch_Clicked" Icon="Add"> </ext:Button>
<ext:Button ID="btnVerwerkNAW" runat="server" Text="Verwerk" OnDirectClick="btnVerwerkNAW_Clicked" Icon="Tick">
<%--<DirectEvents>
<Click OnEvent="Wait"/>
</DirectEvents>--%>
</ext:Button>
<ext:ProgressBar ID="Progress1" runat="server" Width="300" Text="Initializing..." Hidden="true" />
<ext:Button ID="btnClearSelection" runat="server" Text="Mutatie(s) legen" Icon="Delete" OnDirectClick="btnClearSelection_Clicked">
<Listeners>
<Click Handler="MutatieLegen(#{grid});" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<!-- Simple Array Grid -->
<ext:GridPanel ID="grid" runat="server" Title="Wijzigingen" AutoWidth="true" AutoHeight="true" Padding="4" StripeRows="true" Draggable="false" Selectable="true" Icon="Application">
<Store>
<ext:Store ID="Store1" runat="server" WarningOnDirty="false">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="persoonID" Mapping="PersoonsId" />
<ext:RecordField Name="anummer" Mapping="Anummer" />
<ext:RecordField Name="bSNpersoon" Mapping="BSNpersoon" />
<ext:RecordField Name="type" Mapping="TypeWijziging" />
<ext:RecordField Name="datum" Mapping="DatumBinnenhalen" />
<ext:RecordField Name="omschrijving" Mapping="Omschrijving" />
<ext:RecordField Name="foutmelding" Mapping="Foutmelding" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:RowNumbererColumn />
<ext:Column DataIndex="persoonID" Header="Relatie nr." Width="100">
</ext:Column>
<ext:Column DataIndex="anummer" Header="A-nummer" Width="150">
</ext:Column>
<ext:Column DataIndex="bSNpersoon" Header="BSN" Width="150">
</ext:Column>
<ext:Column DataIndex="type" Header="Type wijziging" Width="150">
</ext:Column>
<ext:Column DataIndex="datum" Header="Datum synchroniseren" Width="200">
</ext:Column>
<ext:Column ColumnID="columnStatus" DataIndex="omschrijving" Header="Status" Width="130">
<Renderer Handler="return imgRenderer(value);" />
</ext:Column>
<ext:Column DataIndex="foutmelding" Header="Reden" Width="350">
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="false" />
</SelectionModel>
</ext:GridPanel>
函数javascript客户端删除行:
function MutatieLegen(grid) {
var i = 0;
//var store = Ext.getCmp("grid").getStore();
if (grid.store.getCount() > 0) {
for (i = grid.store.getCount() - 1; i >= 0; i--) {
var status = grid.store.getAt(i).data["omschrijving"];
if (status == "Verwerkt" || status == "Ter Fiattering" || status == "Al verwerkt") {
grid.store.removeAt(i);
}
}
}
后面的代码:
protected void btnClearSelection_Clicked(Object sender, DirectEventArgs e)
{
// Code behind logic. call sql to delete rows where status == Verwerkt or Ter Fiattering or Al verwerkt
}