我写的是这样的
<ext:Store ID="strPos" runat="server" AutoSync="false" OnReadData="StoreChange_Event"
OnBeforeRecordUpdated="StorePostGuncelle" OnBeforeRecordInserted="StorePostEkle"
AutomaticResponseValues="false" OnBeforeRecordDeleted="StorePosSil">
我可以像这样插入价值,
grid.store.insert(0, r);
#{strPos}.sync();
grid.store.reload();
但问题是更新值时。当clcik行,打开行编辑器,然后我clcik更新按钮但没有事件触发。(我想要fireOnBeforeRecordUpdaten事件)。
我已经尝试过了,
<Plugins>
<ext:RowEditing ID="RowEditing1" runat="server" CancelBtnText="İptal" SaveBtnText="Kaydet" ClicksToEdit="1" TriggerEvent="#{strPos}.sync();#{strPos}.reload();" >
</ext:RowEditing>
</Plugins>
和这一个
<Plugins>
<ext:RowEditing ID="RowEditing1" runat="server" CancelBtnText="İptal" SaveBtnText="Kaydet" ClicksToEdit="1" SaveHandler="#{strPos}.sync();#{strPos}.reload();" SaveHandler="" >
</ext:RowEditing>
</Plugins>
但一无所获。 谢谢
** 它是availbale this.up('gridpanel')。store.removeAt(recordIndex);和插入方法,但更新方法在哪里。 编辑:完整的例子;
<ext:XScript ID="XScript1" runat="server">
<script>
function addPlant(btn) {
// Create a model instance
var grid = #{GridPanel1};
grid.editingPlugin.cancelEdit();
var r = Ext.ModelManager.create({
Adi: 'pos bilgisi',
Id:'0'
} ,'Pos');
grid.store.insert(0, r);
#{strPos}.sync();
grid.store.reload();
// grid.editingPlugin.startEditByPosition({ row: 0, column: 1 });
}
</script>
</ext:XScript>
<ext:GridPanel ID="GridPanel1" Scroll="Vertical" runat="server" Title="Pos tanımlamalrı"
Height="200">
<Store>
<ext:Store ID="strPos" runat="server" AutoSync="false" OnReadData="StoreChange_Event" OnAfterStoreChanged="store_change"
OnBeforeRecordUpdated="StorePostGuncelle" OnBeforeRecordInserted="StorePostEkle"
AutomaticResponseValues="false" OnBeforeRecordDeleted="StorePosSil">
<Model>
<ext:Model ID="Model1" runat="server" Name="Pos">
<Fields>
<ext:ModelField Name="Id" Type="Int" SortDir="ASC" />
<ext:ModelField Name="Adi" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="Button1" runat="server" Text="Pos ekle" Handler="addPlant" Icon="Add" />
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="Column7" runat="server" Text="Id" DataIndex="Id" Flex="1">
</ext:Column>
<ext:Column ID="Column8" runat="server" Text="Banka adı" DataIndex="Adi" Flex="1">
<Editor>
<ext:TextField ID="txtAd" runat="server" AllowBlank="false" />
</Editor>
</ext:Column>
<ext:ImageCommandColumn ID="ImageCommandColumn1" runat="server" Width="30" Sortable="false">
<Commands>
<ext:ImageCommand Icon="Decline" ToolTip-Text="Delete Plant" CommandName="delete">
</ext:ImageCommand>
</Commands>
<Listeners>
<Command Handler="this.up('gridpanel').store.removeAt(recordIndex);#{strPos}.sync();" />
</Listeners>
</ext:ImageCommandColumn>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="rowSelectionModel1" runat="server">
</ext:RowSelectionModel>
</SelectionModel>
<Plugins>
<ext:RowEditing ID="RowEditing1" runat="server" CancelBtnText="İptal" SaveBtnText="Kaydet" ClicksToEdit="0" SaveHandler="#{strPos}.sync();" >
</ext:RowEditing>
</Plugins>
</ext:GridPanel>
后面的代码就在这里
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
strPos.DataSource = ps.Getir();
strPos.DataBind();
}
}
protected void StoreChange_Event(object sender, EventArgs e)
{
strPos.DataSource = ps.Getir();
strPos.DataBind();
}
protected void store_change(object sender, AfterStoreChangedEventArgs e)
{
strPos.DataSource = ps.Getir();
strPos.DataBind();
}
public void StorePostEkle(object sender, BeforeRecordInsertedEventArgs e)
{
// string ss = e.Record.ToString();
Pos pss = e.Object<Pos>();
ps.Ekle(pss);
X.Msg.Notify("store", "storea veri eklendi" + e.Record).Show();
// GridPanel1.Reload();
}
protected void StorePosSil(object sender, BeforeRecordDeletedEventArgs e)
{
X.Msg.Notify("store", "storea dan veri, silindi " + e.Record).Show();
Pos pss = e.Object<Pos>();
try
{
ps.Sil(pss.Id);
}
catch (Exception)
{
throw;
}
}
protected void StorePostGuncelle(object sender, BeforeRecordUpdatedEventArgs e)
{
X.Msg.Notify("store", "storea güncellendi " + e.Record).Show();
Pos pss = e.Object<Pos>();
// Pos pss = JSON.Deserialize<Pos>(e.ToString());
ps.Guncelle(pss);