Ext.Net从数据库中删除(只是客户端删除)
本文关键字:删除 客户端 Ext 数据库 Net | 更新日期: 2023-09-27 18:21:10
我正试图在我的项目中使用ext.net网格面板。重点是我不能从数据库中删除存储数据。我添加了行命令和按钮,尝试用直接方法删除。但没有被解雇。我在代码后面使用实体框架,并用它存储网格面板。当我单击行命令删除或编辑时,我如何从数据库中删除或编辑存储。我是缺少代理还是其他方法?我是ext.net的新手。
**
<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Control Test"
Width="700">
<Store>
<ext:Store ID="Store1" runat="server" OnReadData="Store1_ReadData" AutoSync="true" PageSize="10">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="ID" />
<ext:ModelField Name="Controllor" />
<ext:ModelField Name="Process" />
<ext:ModelField Name="Control" />
<ext:ModelField Name="ControlType" />
<ext:ModelField Name="ControlPlace" />
<ext:ModelField Name="AuditeeUnit" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="35" />
<ext:Column ID="Column1" runat="server" Text="Controllor" DataIndex="Controllor" Flex="1" />
<ext:Column ID="Column2" runat="server" Text="Process" Width="75" DataIndex="Process">
</ext:Column>
<ext:Column ID="Column3" runat="server" Text="Control" Width="75" DataIndex="Control">
</ext:Column>
<ext:Column ID="Column4" runat="server" Text="Control Type" Width="75" DataIndex="ControlType">
</ext:Column>
<ext:Column ID="Column5" runat="server" Text="Control Area" Width="75" DataIndex="ControlPlace">
</ext:Column>
<ext:Column ID="Column6" runat="server" Text="Unit" Width="75" DataIndex="AuditeeUnit">
</ext:Column>
<ext:CommandColumn ID="CommandColumn1" runat="server" Width="60">
<Commands>
<ext:GridCommand Icon="Delete" CommandName="Delete" OnDataBinding="Unnamed_DataBinding" AutoDataBind="True">
<ToolTip Text="Delete" />
</ext:GridCommand>
<ext:CommandSeparator />
<ext:GridCommand Icon="NoteEdit" CommandName="Edit">
<ToolTip Text="Edit" />
</ext:GridCommand>
</Commands>
<Listeners>
<Command Handler="if (command == 'Delete') {App.direct.testmethod();}"/>
</Listeners>
</ext:CommandColumn>
</Columns>
</ColumnModel>
<TopBar>
<ext:Toolbar ID="UsersGridPanelPowerUserToolbar" runat="server">
<Items>
<ext:Button ID="UserRemoveButton" runat="server" Text="Delete" Icon="Delete" Disabled="false" StandOut="true">
<Listeners>
<Click Handler="App.direct.testmethod();" />
</Listeners>
<DirectEvents>
<Click OnEvent="Unnamed_Event"></Click>
</DirectEvents>
</ext:Button>
<ext:ToolbarSeparator></ext:ToolbarSeparator>
</Items>
</ext:Toolbar>
</TopBar>
<SelectionModel>
<ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" Mode="Multi" />
</SelectionModel>
<View>
<ext:GridView ID="GridView1" runat="server" StripeRows="true" />
</View>
<BottomBar>
<ext:PagingToolbar ID="PagingToolbar1" runat="server">
<Items>
<ext:Label ID="Label1" runat="server" Text="Page size:" />
<ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
<ext:ComboBox ID="ComboBox1" runat="server" Width="80">
<Items>
<ext:ListItem Text="1" />
<ext:ListItem Text="2" />
<ext:ListItem Text="10" />
<ext:ListItem Text="20" />
</Items>
<SelectedItems>
<ext:ListItem Value="10" />
</SelectedItems>
<Listeners>
<Select Handler="#{GridPanel1}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanel1}.store.reload();" />
</Listeners>
</ext:ComboBox>
</Items>
<Plugins>
<ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
</Plugins>
</ext:PagingToolbar>
</BottomBar>
</ext:GridPanel>
**
[DirectMethod]
public void testmethod()
{
X.Msg.Alert("DirectMethod", "hello").Show();
ModelProxy prox = new ModelProxy(Store1);
//AbstractProxy absprox = JsonPProxy
prox.Store.DataBind();
//prox.Destroy();
//prox.Store.ServerProxy.RemoveAt();
prox.Store.Destroy();//tested for data deletion
Store1.CommitChanges();//it has sent communicate for changed data at server data
}
也许这对你有帮助:
http://msdn.microsoft.com/en-gb/library/ms228366%28v=vs.80%29.aspx
只需将连接字符串更改为您自己的连接字符串,并使用类似的内容更改SELECT
语句
"DELETE FROM <Table> WHERE ID= "+selectedRowID
请确保提供服务器端方法所选行的ID
:
App.direct.testmethod(record.data.ID);