[CLOSED] Inserted records dissapear after local sort operation

  1. #1

    [CLOSED] Inserted records dissapear after local sort operation

    Hello,

    after inserting some records in a store and displaying them within a grid which is connected to this store i am trying to perform a sort operation on the grid (by clicking on the grid header - all operations performed locally). All records which were added since last saving the grid get lost then.

    <ext:Store runat="server" ID="_storeAddress" AutoLoad="True">
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="ID" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    
    <ext:GridPanel ID="_addressEntryGrid" runat="server" StoreID="_storeAddress" Title="Addresseinträge" AutoScroll="True" AutoHeight="True" ButtonAlign="Center" ClicksToEdit="2" StripeRows="True" TrackMouseOver="True" EnableColumnHide="False" EnableColumnMove="False" AutoWidth="True" AutoExpandColumn="ID">
        <ColumnModel ID="_addressEntryColumnModel" runat="server">
            <Columns>
                <ext:Column ColumnID="ID" Header="ID" DataIndex="ID" Width="120">
                </ext:Column>
            </Columns>
        </ColumnModel>
        <LoadMask ShowMask="true" />
        <SelectionModel>
            <ext:RowSelectionModel ID="_addressEntrySelectionModel" runat="server" SingleSelect="true">
            </ext:RowSelectionModel>
        </SelectionModel>
        <View>
            <ext:GridView runat="server" ID="_addressEntryGridView" />
        </View>
    </ext:GridPanel>
    
    <script type="text/javascript">
    function CreateAddressEntryRecord() {
        // Insert record - call it to insert test record
        var grid = Ext.getCmp('<%=addressEntryGrid.ClientID%>').getValue();
        
        var rec = 
        {
            ID: 0
        };
        
        grid .insertRecord(0, rec);
    }
    </script>

    I am using Coolite 0.8 latest trunk.
    Is this default behaviour ?

    However, as a workaround I would like to display a confirmation message BEFORE the user performs a sort operation on the grid. If the user clicks "yes" then sorting should be performed otherwise it has to be canceled.

    I couldn`t find any event that could help me.

    Do you have any ideas how to archieve this ? Please help me, thank you very much !

    Thx,
    Peter
  2. #2

    RE: [CLOSED] Inserted records dissapear after local sort operation

    Hi,

    1. grid has no getValue method therefore the following is incorrect
    var grid = Ext.getCmp('<%=_addressEntryGrid.ClientID%>').getValue;
    2. New records should not be lost after sorting (if sort is local). And your example doesn't reproduce it

    Here is my test case
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ScriptManager ID="ScriptManager1" runat="server" Theme="Gray" />
    
        <ext:Store runat="server" ID="_storeAddress" AutoLoad="True">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="ID" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        
        <ext:GridPanel ID="_addressEntryGrid" runat="server" StoreID="_storeAddress" Title="Addresseinträge"
            AutoScroll="True" AutoHeight="True" ButtonAlign="Center" ClicksToEdit="2" StripeRows="True"
            TrackMouseOver="True" EnableColumnHide="False" EnableColumnMove="False" AutoWidth="True"
            AutoExpandColumn="ID">
            <ColumnModel ID="_addressEntryColumnModel" runat="server">
                <Columns>
                    <ext:Column ColumnID="ID" Header="ID" DataIndex="ID" Width="120">
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <LoadMask ShowMask="true" />
            <SelectionModel>
                <ext:RowSelectionModel ID="_addressEntrySelectionModel" runat="server" SingleSelect="true">
                </ext:RowSelectionModel>
            </SelectionModel>
            <View>
                <ext:GridView runat="server" ID="_addressEntryGridView" />
            </View>
        </ext:GridPanel>
        
        <ext:Button runat="server" Text="Insert">
            <Listeners>
                <Click Fn="CreateAddressEntryRecord" />
            </Listeners>
        </ext:Button>
    
        <script type="text/javascript">
        function CreateAddressEntryRecord() {
            // Insert record - call it to insert test record
            var grid = Ext.getCmp('<%=_addressEntryGrid.ClientID%>');
            
            var rec = 
            {
                ID: 0
            };
            
            grid.insertRecord(0, rec);
        }
        </script>
    
        </form>
    </body>
    </html>
  3. #3

    RE: [CLOSED] Inserted records dissapear after local sort operation

    Oh, i am very sorry vlad. I`ve found out that I have to include a paging toolbar to make this behaviour happen.

    So here is my updated example which reproduces the problem described above.

    Default.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Ilogs.Coolite.Sample.Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ScriptManager ID="ScriptManager1" runat="server" Theme="Gray" />
    
        <ext:Store runat="server" ID="_storeAddress" AutoLoad="True">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="ID" />
                        <ext:RecordField Name="ID2" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        
        <ext:GridPanel ID="_addressEntryGrid" runat="server" StoreID="_storeAddress" Title="Addresseinträge"
            AutoScroll="True" AutoHeight="True" ButtonAlign="Center" ClicksToEdit="2" StripeRows="True"
            TrackMouseOver="True" EnableColumnHide="False" EnableColumnMove="False" AutoWidth="True"
            AutoExpandColumn="ID">
            <ColumnModel ID="_addressEntryColumnModel" runat="server">
                <Columns>
                    <ext:Column ColumnID="ID" Header="ID" DataIndex="ID" Width="120">
                    </ext:Column>
                    <ext:Column ColumnID="ID2" Header="ID" DataIndex="ID2" Width="120">
                        <Renderer Handler="return value;" />
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <LoadMask ShowMask="true" />
            <Plugins>
                <ext:GridFilters runat="server" ID="CommunicationsGridFilters" Local="true">
                    <Filters>
                        <ext:StringFilter DataIndex="ID" />
                        <ext:StringFilter DataIndex="ID" />
                    </Filters>
                </ext:GridFilters>
            </Plugins>
            <SelectionModel>
                <ext:RowSelectionModel ID="_addressEntrySelectionModel" runat="server" SingleSelect="true">
                </ext:RowSelectionModel>
            </SelectionModel>
            <View>
                <ext:GridView runat="server" ID="_addressEntryGridView" >
                        <HeaderRows>
                            <ext:HeaderRow>
                                <Columns>
                                    <ext:HeaderColumn>
                                        <Component>
                                            <ext:TextField ID="FilterID" runat="server" EnableKeyEvents="true">
                                            </ext:TextField>
                                        </Component>
                                    </ext:HeaderColumn>
                                     <ext:HeaderColumn>
                                        <Component>
                                            <ext:TextField ID="FilterID2" runat="server" EnableKeyEvents="true">
                                            </ext:TextField>
                                        </Component>
                                    </ext:HeaderColumn>
                                </Columns>
                            </ext:HeaderRow>
                        </HeaderRows>
                </ext:GridView>
            </View>
        <BottomBar>
            <ext:PagingToolBar ID="PagingToolBar2" runat="server" DisplayMsg="{0} - {1} von {2}" EmptyMsg="Keine Einträge">
                <Items>
                    <ext:Button ID="_insert" runat="server" Text="Insert">
                        <Listeners>
                            <Click Fn="CreateAddressEntryRecord" />
                        </Listeners>
                    </ext:Button>
                </Items>
            </ext:PagingToolBar>
        </BottomBar>
        </ext:GridPanel>
        
        <script type="text/javascript">
        function CreateAddressEntryRecord() {
            // Insert record - call it to insert test record
            var grid = Ext.getCmp('<%=_addressEntryGrid.ClientID%>');
            
            var rec =
            {
                ID: Math.random(),
                ID2: Math.random()
            };
            
            grid.insertRecord(0, rec);
        }
        </script>
    
        </form>
    </body>
    </html>
    Default.aspx.cs
    using System;
    using System.Collections.Generic;
    
    namespace Ilogs.Coolite.Sample
    {
        public class RemoteObject
        {
            public string ID
            {
                get; set;
            }
    
            public string ID2
            {
                get;
                set;
            }
        }
    
        public partial class Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                _storeAddress.DataSource = new List<RemoteObject> {new RemoteObject() {ID = "123", ID2 = "456"}};
                _storeAddress.DataBind();
            }
        }
    }
    What can I do ?

    Thank you very much !

    Thx,
    Peter
  4. #4

    RE: [CLOSED] Inserted records dissapear after local sort operation

    Hi,

    Please add the following code after 'insertRecord'
    grid.store.load(grid.store.lastOptions);

    Also I think it is better to remove
    <LoadMask ShowMask="true" />

    because mask is not required for local operations

Similar Threads

  1. [CLOSED] Keep TreePanel´s selection after local sort
    By RCN in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 23, 2012, 7:05 PM
  2. Replies: 4
    Last Post: Jul 25, 2011, 4:57 PM
  3. [CLOSED] Local Paging and loading records via DirectMethods
    By macap in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: May 31, 2011, 3:28 PM
  4. Replies: 4
    Last Post: Nov 11, 2010, 11:46 AM
  5. Sort with Conditional sort direction in JS- help!
    By Tbaseflug in forum 1.x Help
    Replies: 2
    Last Post: May 05, 2009, 12:11 PM

Posting Permissions