[CLOSED] Different behavior of adding a record to a grid in 2.2

  1. #1

    [CLOSED] Different behavior of adding a record to a grid in 2.2

    Hello,

    I have recently upgraded to ExtNet 2.2
    I have a grid (Grid A) that allows to copy records into another grid (Grid B)

    Since 2.2 the newly added record in Grid B always gets automatically selected. I do not want to get it selected at that moment because I have a select handler that is triggering now every time when I add a record to the grid. Is there any property to disable that behavior?

    Regards
    Last edited by Daniil; Apr 11, 2013 at 3:22 PM. Reason: [CLOSED]
  2. #2
    Hi @blueworld,

    I can't reproduce. A new added row is not selected in the test case below. Please provide your test case.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test1", "test2", "test3" },
                    new object[] { "test4", "test5", "test6" },
                    new object[] { "test7", "test8", "test9" }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Button runat="server" Text="Add" Handler="App.GridPanel1.getStore().add({});" />
    
            <ext:GridPanel ID="GridPanel1" runat="server">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="test1" />
                                    <ext:ModelField Name="test2" />
                                    <ext:ModelField Name="test3" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test1" DataIndex="test1" />
                        <ext:Column runat="server" Text="Test2" DataIndex="test2" />
                        <ext:Column runat="server" Text="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil,
    please see my simplified example, and yes here it does always select the new record which did not happen in 2.0, click the lorry icon to copy:

    
    <script runat="server" >
        
    Protected Sub Page_Load(sender As Object, e As EventArgs)
            If Not ExtNet.IsAjaxRequest Then
                Dim store As Store = Me.GridPanel1.GetStore()
                store.DataSource = New Object() {New Object() {"test1", "test2", "test3"}, New Object() {"test4", "test5", "test6"}, New Object() {"test7", "test8", "test9"}}
                store.DataBind()
            End If
        End Sub
        
        
    </script>
    <%@ Page Language="VB"  %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>Ext.NET v2 Example</title>
        <script>
    
            function addData(record) {
                       var oldTest1 = record.get('test1')
                       var newRecord = record.copy();
                       // newRecord.data.test1 = <img src='ajaxpreloader.gif />
                       App.GridPanel2.store.insert(0, newRecord.data);
                      // calling a webservice and showing an ajax preloader in the column test1.
    
                       //webservice finished, set test1 to its old value:
                       newRecord = App.GridPanel2.getStore().getById(record.data.test1);
                       newRecord.set("test1",oldTest1);
                       newRecord.commit();
                    }      
        
    
    
        </script>
    </head>
        
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:Button ID="Button1" runat="server" Text="Add" Handler="App.GridPanel1.getStore().add({});" />
     
            <ext:GridPanel ID="GridPanel1" runat="server">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model ID="Model1" runat="server" >
                                <Fields>
                                    <ext:ModelField Name="test1" />
                                    <ext:ModelField Name="test2" />
                                    <ext:ModelField Name="test3" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ID="Column1" runat="server" Text="Test1" DataIndex="test1" />
                        <ext:Column ID="Column2" runat="server" Text="Test2" DataIndex="test2" />
                        <ext:Column ID="Column3" runat="server" Text="Test3" DataIndex="test3" />
                                                                    <ext:ImageCommandColumn ID="CommandColumn5" runat="server" Width="30">
                                                <Commands>
                                                    <ext:ImageCommand Icon="LorryGo" CommandName="addToSecondGrid">
                                                        <ToolTip Text="Add to second Grid" />
                                                    </ext:ImageCommand>
                                                </Commands>
                                                <Listeners>
                                                    <Command Handler="addData(record);" />
                                                    
                                                </Listeners>
                                            </ext:ImageCommandColumn>
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
                    <ext:GridPanel ID="GridPanel2" runat="server" >
                <Store>
                    <ext:Store ID="Store2" runat="server" >
                        <Model>
                            <ext:Model ID="Model2" runat="server" IDProperty="test1">
                                <Fields>
                                    <ext:ModelField Name="test1" />
                                    <ext:ModelField Name="test2" />
                                    <ext:ModelField Name="test3" />
    
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel2" runat="server">
                    <Columns>
                        <ext:Column ID="Column4" runat="server" Text="Test1" DataIndex="test1" />
                        <ext:Column ID="Column5" runat="server" Text="Test2" DataIndex="test2" />
                        <ext:Column ID="Column6" runat="server" Text="Test3" DataIndex="test3" />
    
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Last edited by blueworld; Apr 11, 2013 at 9:02 AM.
  4. #4
    Thank you for a test case. Reproduced. We are investigating.

    For now I can suggest to set up SelectionMemory="false" for the GridPanel.
  5. #5
    Regarding this:
    newRecord.set("test1",oldTest1);
    To set up a record's id, please use the setId method.
    http://docs.sencha.com/ext-js/4-2/#!...l-method-setId

    It would be even better to avoid changing an id if possible.
  6. #6
    It has been fixed in SVN, please update and retest.
  7. #7
    Quote Originally Posted by Daniil View Post
    Regarding this:
    newRecord.set("test1",oldTest1);
    To set up a record's id, please use the setId method.
    http://docs.sencha.com/ext-js/4-2/#!...l-method-setId

    It would be even better to avoid changing an id if possible.
    Hi Daniil,

    in my real application I am changing my description property which is not the id, but thank you for the hint, I have just used randomly test1 in the example. What I do is showing an ajax preloader in the description column as long as the webservice does the request, and then displaying the original value again instead of the gif.

    I will report back later if the SVN Update did help, thank you
    Last edited by blueworld; Apr 11, 2013 at 10:54 AM.
  8. #8
    Hi Daniil,

    the grid is now exactly working as before, thank you.
  9. #9
    Thank you for confirming!

Similar Threads

  1. [CLOSED] Adding a new grid record
    By adelaney in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Jun 06, 2012, 3:14 PM
  2. [CLOSED] Adding New Record at run time
    By jesperhp in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 27, 2012, 12:17 PM
  3. [CLOSED] [1.0] Store adding record
    By state in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Dec 11, 2009, 6:24 PM
  4. [CLOSED] Adding a new Store Record - Not a Record object
    By Steve in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 15, 2009, 7:40 AM
  5. Adding one record in a grid
    By nuno_Santos in forum 1.x Help
    Replies: 1
    Last Post: Apr 14, 2009, 5:55 PM

Posting Permissions