[CLOSED] Grid Panel data erasure problem

  1. #1

    [CLOSED] Grid Panel data erasure problem

    Hi,

    There is a grid panel with paging toolbar.

    First, I clear the store with removeAll method. Then I reload the gridpanel with a new data source.

    But after that, if a record is deleted from the store, it clears all the store.

    If I dont use paging, this is not occured.


    <%@ Page Language="C#" AutoEventWireup="true"  %>
    
    <!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 id="Head1" runat="server">
        <meta http-equiv="X-UA-Compatible" content="IE=11; IE=10; IE=9; IE=8; IE=edge,chrome=1" />
        <asp:Literal runat="server" ID="ltrlHead" EnableViewState="false" />
    </head>
    <body>
        <form id="form2" runat="server">
            <%--<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuestionnaireParameterLife.aspx.cs" Inherits="LifeIn.UI.Web.Parameter.CallCenter.QuestionnaireParameterLife" MasterPageFile="~/AppContentFrame.Master" %>--%>
              <ext:ResourceManager ID="rmMaster" runat="server">
            </ext:ResourceManager>
            <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
            <script runat="server">
                protected void Page_Load(object sender, EventArgs e)
                {
                    GetItems();
                }
                [DirectMethod]
                public void GetItems()
                {
                    Store1.DataSource = new object[]
                     {
                    new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
                    new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
                    new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
                    new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
                    new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" },
                    new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am" },
                    new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am" },
                    new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04, "9/1 12:00am" },
                    new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28, "9/1 12:00am" },
                    new object[] { "Exxon Mobil Corp", 68.1, -0.43, -0.64, "9/1 12:00am" },
                    new object[] { "General Electric Company", 34.14, -0.08, -0.23, "9/1 12:00am" },
                    new object[] { "General Motors Corporation", 30.27, 1.09, 3.74, "9/1 12:00am" },
                    new object[] { "Hewlett-Packard Co.", 36.53, -0.03, -0.08, "9/1 12:00am" },
                    new object[] { "Honeywell Intl Inc", 38.77, 0.05, 0.13, "9/1 12:00am" },
                    new object[] { "Intel Corporation", 19.88, 0.31, 1.58, "9/1 12:00am" },
                    new object[] { "International Business Machines", 81.41, 0.44, 0.54, "9/1 12:00am" },
                    new object[] { "Johnson & Johnson", 64.72, 0.06, 0.09, "9/1 12:00am" },
                    new object[] { "JP Morgan & Chase & Co", 45.73, 0.07, 0.15, "9/1 12:00am" },
                    new object[] { "McDonald\"s Corporation", 36.76, 0.86, 2.40, "9/1 12:00am" },
                    new object[] { "Merck & Co., Inc.", 40.96, 0.41, 1.01, "9/1 12:00am" },
                    new object[] { "Microsoft Corporation", 25.84, 0.14, 0.54, "9/1 12:00am" },
                    new object[] { "Pfizer Inc", 27.96, 0.4, 1.45, "9/1 12:00am" },
                    new object[] { "The Coca-Cola Company", 45.07, 0.26, 0.58, "9/1 12:00am" },
                    new object[] { "The Home Depot, Inc.", 34.64, 0.35, 1.02, "9/1 12:00am" },
                    new object[] { "The Procter & Gamble Company", 61.91, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "United Technologies Corporation", 63.26, 0.55, 0.88, "9/1 12:00am" },
                    new object[] { "Verizon Communications", 35.57, 0.39, 1.11, "9/1 12:00am" },
                    new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, "9/1 12:00am" }
                     };
                    Store1.DataBind();
                }
            </script>
            <script type="text/javascript">
    
                var clearPage = function () {
                    <%=Store1.ClientID%>.removeAll();
            }
            var GetItems = function(){
                App.direct.GetItems({
                    eventMask: {
                        showMask: true
                    },
                });
            }
            var gpItemCommand = function(command, record) {            
                switch (command) {
                    case "Delete":
                        record.data.ActionType = 3;
                        <%=Store1.ClientID %>.removeAt( <%=Store1.ClientID %>.indexOf(record)); 
                        break;
                }
            }
            </script>
            <ext:Container runat="server" Layout="FitLayout">
                <Bin>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="company" />
                                    <ext:ModelField Name="price" Type="Float" />
                                    <ext:ModelField Name="change" Type="Float" />
                                    <ext:ModelField Name="pctChange" Type="Float" />
                                    <ext:ModelField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Bin>
                <Items>
                    <ext:FormPanel ID="formPanelContent" runat="server" BodyPadding="5" Border="false" Layout="VBoxLayout" IDMode="Static" >
                        <TopBar>
                            <ext:Toolbar ID="tbTop" runat="server">
                                <Items>
                                    <ext:Button ID="btnClear" runat="server" Icon="PageWhite" Text="Clear Page"
                                        IDMode="Static">
                                        <Listeners>
                                            <Click Handler="clearPage();" />
                                        </Listeners>
                                    </ext:Button>
    
                                    <ext:Button ID="btnRefresh" runat="server" Icon="ArrowRefresh"  Text="Refresh"
                                        IDMode="Static">
                                        <Listeners>
                                            <Click Handler="GetItems();" />
                                        </Listeners>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <Items>
                            <ext:GridPanel runat="server" ID="GridPanel1" StoreID="Store1" MarginSpec="0 0 5 0" Flex="1"
                                Width="650" Border="true" IDMode="Static">
                                <ColumnModel runat="server">
                                    <Columns>
                                        <ext:CommandColumn ID="gp_colDelete" runat="server" Width="30px">
                                            <Commands>
                                                <ext:GridCommand Icon="Delete" CommandName="Delete" />
                                            </Commands>
                                            <Listeners>
                                                <Command Handler="gpItemCommand(command, record);" />
                                            </Listeners>
                                        </ext:CommandColumn>
                                        <ext:Column ID="CompanyColumn" runat="server" Text="Company" Width="160" DataIndex="company" Flex="1" Pattern="{value:uppercase}" />
                                        <ext:Column ID="PriceColumn" runat="server" Text="Price" Width="75" DataIndex="price">
                                            <Renderer Format="UsMoney" />
                                        </ext:Column>
                                        <ext:Column ID="ChangeColumn" runat="server" Text="Change" Width="75" DataIndex="change" />
                                        <ext:Column ID="ChangePrtColumn" runat="server" Text="Change %" Width="75" DataIndex="pctChange" />
                                        <ext:DateColumn ID="LastChangeColumn" runat="server" Text="Last Updated" Width="85" DataIndex="lastChange" />
                                    </Columns>
                                </ColumnModel>
    
                                <BottomBar>
                                    <ext:PagingToolbar ID="ptQuestionnaire" runat="server">
                                    </ext:PagingToolbar>
                                </BottomBar>
                            </ext:GridPanel>
    
                        </Items>
                    </ext:FormPanel>
                </Items>
            </ext:Container>
        </form>
    </body>
    </html>
    Thanks,

    Vzx
    Last edited by Daniil; Sep 22, 2015 at 3:18 PM. Reason: [CLOSED]
  2. #2
    Hi @vzx,

    Please clarify the steps. Is it the following?

    1. Click the Clear Page button
    2. Click the Refresh button
    3. Click the delete icon in some row
    4. GridPanel becomes empty

    I could not reproduce it. The GridPanel doesn't become empty for me.

    Please also share Ext.NET version you are dealing with.
  3. #3
    I am using 3.1 version of Ext.Net.

    Can you try the case with that version? If not, I can try it with latest version.

    Thanks,

    Vzx
  4. #4
    Yes, I could reproduce it with 3.1.0. Fortunately, it has been fixed in 3.2.
  5. #5
    Thanks Daniil.

Similar Threads

  1. Replies: 0
    Last Post: Jul 27, 2015, 12:51 PM
  2. Replies: 13
    Last Post: Sep 26, 2013, 10:04 AM
  3. Replies: 13
    Last Post: Feb 28, 2013, 2:06 PM
  4. Replies: 16
    Last Post: Feb 23, 2011, 10:03 AM
  5. Retieving Data from data base in the Grid Panel
    By Rakeshkumar.a in forum 1.x Help
    Replies: 0
    Last Post: Oct 13, 2010, 6:18 AM

Tags for this Thread

Posting Permissions