1

我正在尝试在我的项目中使用 ext.net gridpanel。关键是我无法从数据库中删除存储数据。我添加了行命令和按钮以尝试使用直接方法删除。但没有被解雇。我正在使用实体框架背后的代码并用它存储网格面板。当我单击行命令删除或编辑时,如何从数据库中删除或编辑存储。我错过代理或其他方法吗?我是 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

    }
4

1 回答 1

0

也许这可以帮助你:

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);
于 2013-07-08T10:38:36.220 回答