The event "OnBeforeStoreChanged" of Store object can not be fired by GridPanel.deleteSelected()

  1. #1

    The event "OnBeforeStoreChanged" of Store object can not be fired by GridPanel.deleteSelected()

    The event "OnBeforeStoreChanged" of Store object can not be fired by GridPanel.deleteSelected() but GridPanel.insertRecord

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test2.aspx.cs" Inherits="test2" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server">
        </ext:ResourceManager>
        <ext:GridPanel ID="GridPanel1" runat="server" Height="200">
            <SaveMask ShowMask="true" />
            <LoadMask ShowMask="true" />
            <View>
                <ext:GridView ID="GridView1" runat="server" MarkDirty="false" />
            </View>
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
            </SelectionModel>
            <Store>
                <ext:Store ID="Store1" runat="server" AutoSave="true" OnRefreshData="DB_Refresh"
                    OnBeforeStoreChanged="DB_Changed">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Reader>
                        <ext:JsonReader>
                            <Fields>
                                <ext:RecordField Name="col0" />
                                <ext:RecordField Name="col1" />
                                <ext:RecordField Name="col2" />
                                <ext:RecordField Name="col3" />
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column ColumnID="col0" Header="col0" DataIndex="col0" Hidden="true">
                    </ext:Column>
                    <ext:Column ColumnID="col1" Header="col1" DataIndex="col1">
                    </ext:Column>
                    <ext:Column ColumnID="col2" Header="col2" DataIndex="col2">
                    </ext:Column>
                    <ext:Column ColumnID="col3" Header="col3" DataIndex="col3" Hidden="true">
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <TopBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                    <Items>
                        <ext:Button ID="AddBtn" runat="server" Text="添加" Icon="Add">
                            <Listeners>
                                <Click Handler="alert('add click');" />
                            </Listeners>
                        </ext:Button>
                        <ext:Button ID="DeleteBtn" runat="server" Text="删除" Icon="Cross">
                            <Listeners>
                                <Click Handler="#{GridPanel1}.deleteSelected();" />
                            </Listeners>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
        </ext:GridPanel>
        </form>
    </body>
    </html>
    code behind

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Ext.Net;
    
    class test
    {
        private int _col0;
        private int _col1;
        private int _col2;
        private int _col3;
    
        
        public int col0
        {
            get { return _col0; }
            set { _col0 = value; }
        }
    
        public int col1
        {
            get { return _col1; }
            set { _col1 = value; }
        }
    
        public int col2
        {
            get { return _col2; }
            set { _col2 = value; }
        }
    
        public int col3
        {
            get { return _col3; }
            set { _col3 = value; }
        }
    }
    public partial class test2 : System.Web.UI.Page
    {
    
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void DB_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            
            test abc = new test{col0=0, col1=1, col2=2, col3=3};
    
            List<test> source = new List<test>();
            source.Add(abc);
    
            Store1.DataSource = source;
            Store1.DataBind();
        }
    
        protected void DB_Changed(object sender, BeforeStoreChangedEventArgs e)
        {
            X.Msg.Alert("alert", "call from codebehind!").Show();
    
        }
    }
  2. #2
    Hi,

    According to
    http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-cfg-autoSave
    AutoSave="true" deals with modified records only.

    When you insert a record using the GridPanel's insertRecord() method, a record's fields values are changed, so a record is considered as modified/dirty and, respectively, auto-saving occurs.

    You should manually save a data when you delete a record.

    NOTE: The above is wrong. Please see the next post.
    Last edited by Daniil; Jan 09, 2012 at 10:52 PM.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    According to
    http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-cfg-autoSave
    AutoSave="true" deals with modified records only.

    When you insert a record using the GridPanel's insertRecord() method, a record's fields values are changed, so a record is considered as modified/dirty and, respectively, auto-saving occurs.

    You should manually save a data when you delete a record.
    This is wrong.

    Please see the following post:
    http://forums.ext.net/showthread.php...ll=1#post72071

Similar Threads

  1. Replies: 1
    Last Post: Apr 09, 2012, 11:42 AM
  2. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  3. Replies: 2
    Last Post: Jun 26, 2011, 1:59 AM
  4. Problem about store event "OnRefreshData"
    By zhangsir199 in forum 1.x Help
    Replies: 1
    Last Post: Jan 04, 2011, 9:33 AM
  5. Replies: 1
    Last Post: Jan 15, 2010, 12:55 PM

Tags for this Thread

Posting Permissions