当单击插入按钮(btnSinifEkle)时,我的事件通过 OnBeforeRecordInserted="tetikle4" 触发。即使我单击取消按钮,它已经通过 OnBeforeRecordInserted 插入并显示在网格内。我怎样才能避免这种情况。另外,当我单击插入按钮时,记录显示在网格内,即使我不告诉更新或取消。
太感谢了。
<ext:XScript ID="XScript1" runat="server">
<script>
var sinifEkle = function () {
var grid = #{gridSinif};
grid.editingPlugin.cancelEdit();
// Create a record instance through the ModelManager
var r = Ext.ModelManager.create({
SinifAd: 'yeni sınıf',
}, 'Sinif');
grid.store.insert(0, r);
grid.editingPlugin.startEdit(0, 0);
};
var sinifSil = function () {
var grid = #{gridSinif},
sm = grid.getSelectionModel();
grid.editingPlugin.cancelEdit();
grid.store.remove(sm.getSelection());
if (grid.store.getCount() > 0) {
sm.select(0);
}
};
</script>
</ext:XScript>
<ext:GridPanel ID="gridSinif" runat="server" Width="250" Height="300" Title="Sınıf tanımlama"
Frame="true">
<Store>
<ext:Store ID="SinifStore" runat="server" AutomaticResponseValues="false" OnAfterStoreChanged="tetikle"
OnBeforeRecordUpdated="tetikle1" OnBeforeRecordDeleted="tetikle3" AutoSync="true" OnBeforeRecordInserted="tetikle4">
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="SinifId" Name="Sinif">
<Fields>
<ext:ModelField Name="SinifId" Type="Int" />
<ext:ModelField Name="SinifAd" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Plugins>
<ext:RowEditing ID="RowEditing1" runat="server" ClicksToMoveEditor="1" AutoCancel="false" />
</Plugins>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="btnSinifEkle" runat="server" Text="Sınıf ekle" Icon="Add">
<Listeners>
<Click Fn="sinifEkle" />
</Listeners>
</ext:Button>
<ext:Button ID="btnSinifSil" runat="server" Text="Sınıf sil" Icon="Delete" Disabled="true">
<Listeners>
<Click Fn="sinifSil" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="Column1" runat="server" Text="ID" DataIndex="SinifId" Width="35" />
<ext:Column ID="Column3" runat="server" Text="Sınıf adı" DataIndex="SinifAd" Flex="1">
<Editor>
<ext:TextField runat="server" />
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Listeners>
<SelectionChange Handler="#{btnSinifSil}.setDisabled(!selected.length);" />
</Listeners>
</ext:GridPanel>