[CLOSED] GridPanel CellEditing tab navigation issue with Buffered Renderer

  1. #1

    [CLOSED] GridPanel CellEditing tab navigation issue with Buffered Renderer

    We're having a new 4.x issue (this appears to not be an issue in 2.x) with editing a grid that is using buffered rendering. Our grid has a single editable column using the CellEditing plugin, and users hit tab to scroll down the grid while making edits. After about tabbing down ~25 rows, the focus jumps back up to the first row. This is because tabbing down bypasses the normal scrolling mechanism which would otherwise cause the buffered renderer to load the next leading rows. I can delay this issue by increasing the LeadingBufferZone but at the cost of performance. The following is a simple example -- just click in the price cell on the first row and then continue to hit tab until focus jumps back up to the first row -- this should happen after about 25 rows before you get to the bottom of the grid.

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <script runat="server">
        public class Company
        {
            public int ID { get; set; }
            public string Name { get; set; }
            public double Price { get; set; }
            public double Change { get; set; }
            public double PctChange { get; set; }
            public DateTime LastChange { get; set; }
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.BindData();
            }
        }
    
        private void BindData()
        {
            Store store = this.Store1;
            store.DataSource = this.GetData();
            store.DataBind();
        }
    
        private List<Company> GetData()
        {
            DateTime today = DateTime.Today;
    
            return new List<Company>
            {
                new Company { ID = 1, Name = "3m Co", Price = 71.72, Change = 0.02, PctChange = 0.03, LastChange = today },
                new Company { ID = 2, Name = "Alcoa Inc", Price = 29.01, Change = 0.42, PctChange = 1.47, LastChange = today },
                new Company { ID = 3, Name = "Altria Group Inc", Price = 83.81, Change = 0.28, PctChange = 0.34, LastChange = today },
                new Company { ID = 4, Name = "American Express Company", Price = 52.55, Change = 0.01, PctChange = 0.02, LastChange = today },
                new Company { ID = 5, Name = "American International Group, Inc.", Price = 64.13, Change = 0.31, PctChange = 0.49, LastChange = today },
                new Company { ID = 6, Name = "AT&T Inc.", Price = 31.61, Change = -0.48, PctChange = -1.54, LastChange = today },
                new Company { ID = 7, Name = "Boeing Co.", Price = 75.43, Change = 0.53, PctChange = 0.71, LastChange = today },
                new Company { ID = 8, Name = "Caterpillar Inc.", Price = 67.27, Change = 0.92, PctChange = 1.39, LastChange = today },
                new Company { ID = 9, Name = "Citigroup, Inc.", Price = 49.37, Change = 0.02, PctChange = 0.04, LastChange = today },
                new Company { ID = 10, Name = "E.I. du Pont de Nemours and Company", Price = 40.48, Change = 0.51, PctChange = 1.28, LastChange = today },
                new Company { ID = 11, Name = "Exxon Mobil Corp", Price = 68.1, Change = -0.43, PctChange = -0.64, LastChange = today },
                new Company { ID = 12, Name = "General Electric Company", Price = 34.14, Change = -0.08, PctChange = -0.23, LastChange = today },
                new Company { ID = 13, Name = "General Motors Corporation", Price = 30.27, Change = 1.09, PctChange = 3.74, LastChange = today },
                new Company { ID = 14, Name = "Hewlett-Packard Co.", Price = 36.53, Change = -0.03, PctChange = -0.08, LastChange = today },
                new Company { ID = 15, Name = "Honeywell Intl Inc", Price = 38.77, Change = 0.05, PctChange = 0.13, LastChange = today },
                new Company { ID = 16, Name = "Intel Corporation", Price = 19.88, Change = 0.31, PctChange = 1.58, LastChange = today },
                new Company { ID = 17, Name = "International Business Machines", Price = 81.41, Change = 0.44, PctChange = 0.54, LastChange = today },
                new Company { ID = 18, Name = "Johnson & Johnson", Price = 64.72, Change = 0.06, PctChange = 0.09, LastChange = today },
                new Company { ID = 19, Name = "JP Morgan & Chase & Co", Price = 45.73, Change = 0.07, PctChange = 0.15, LastChange = today },
                new Company { ID = 20, Name = "McDonald\"s Corporation", Price = 36.76, Change = 0.86, PctChange = 2.40, LastChange = today },
                new Company { ID = 21, Name = "Merck & Co., Inc.", Price = 40.96, Change = 0.41, PctChange = 1.01, LastChange = today },
                new Company { ID = 22, Name = "Microsoft Corporation", Price = 25.84, Change = 0.14, PctChange = 0.54, LastChange = today },
                new Company { ID = 23, Name = "Pfizer Inc", Price = 27.96, Change = 0.4, PctChange = 1.45, LastChange = today },
                new Company { ID = 24, Name = "The Coca-Cola Company", Price = 45.07, Change = 0.26, PctChange = 0.58, LastChange = today },
                new Company { ID = 25, Name = "The Home Depot, Inc.", Price = 34.64, Change = 0.35, PctChange = 1.02, LastChange = today },
                new Company { ID = 26, Name = "The Procter & Gamble Company", Price = 61.91, Change = 0.01, PctChange = 0.02, LastChange = today },
                new Company { ID = 27, Name = "United Technologies Corporation", Price = 63.26, Change = 0.55, PctChange = 0.88, LastChange = today },
                new Company { ID = 28, Name = "Verizon Communications", Price = 35.57, Change = 0.39, PctChange = 1.11, LastChange = today },
                new Company { ID = 29, Name = "Wal-Mart Stores, Inc.", Price = 45.45, Change = 0.73, PctChange = 1.63, LastChange = today },
                new Company { ID = 30, Name = "3m Co", Price = 71.72, Change = 0.02, PctChange = 0.03, LastChange = today },
                new Company { ID = 31, Name = "Alcoa Inc", Price = 29.01, Change = 0.42, PctChange = 1.47, LastChange = today },
                new Company { ID = 32, Name = "Altria Group Inc", Price = 83.81, Change = 0.28, PctChange = 0.34, LastChange = today },
                new Company { ID = 34, Name = "American Express Company", Price = 52.55, Change = 0.01, PctChange = 0.02, LastChange = today },
                new Company { ID = 35, Name = "American International Group, Inc.", Price = 64.13, Change = 0.31, PctChange = 0.49, LastChange = today },
                new Company { ID = 36, Name = "AT&T Inc.", Price = 31.61, Change = -0.48, PctChange = -1.54, LastChange = today },
                new Company { ID = 37, Name = "Boeing Co.", Price = 75.43, Change = 0.53, PctChange = 0.71, LastChange = today },
                new Company { ID = 38, Name = "Caterpillar Inc.", Price = 67.27, Change = 0.92, PctChange = 1.39, LastChange = today },
                new Company { ID = 39, Name = "Citigroup, Inc.", Price = 49.37, Change = 0.02, PctChange = 0.04, LastChange = today },
                new Company { ID = 40, Name = "E.I. du Pont de Nemours and Company", Price = 40.48, Change = 0.51, PctChange = 1.28, LastChange = today },
                new Company { ID = 41, Name = "Exxon Mobil Corp", Price = 68.1, Change = -0.43, PctChange = -0.64, LastChange = today },
                new Company { ID = 42, Name = "General Electric Company", Price = 34.14, Change = -0.08, PctChange = -0.23, LastChange = today },
                new Company { ID = 43, Name = "General Motors Corporation", Price = 30.27, Change = 1.09, PctChange = 3.74, LastChange = today },
                new Company { ID = 44, Name = "Hewlett-Packard Co.", Price = 36.53, Change = -0.03, PctChange = -0.08, LastChange = today },
                new Company { ID = 45, Name = "Honeywell Intl Inc", Price = 38.77, Change = 0.05, PctChange = 0.13, LastChange = today },
                new Company { ID = 46, Name = "Intel Corporation", Price = 19.88, Change = 0.31, PctChange = 1.58, LastChange = today },
                new Company { ID = 47, Name = "International Business Machines", Price = 81.41, Change = 0.44, PctChange = 0.54, LastChange = today },
                new Company { ID = 48, Name = "Johnson & Johnson", Price = 64.72, Change = 0.06, PctChange = 0.09, LastChange = today },
                new Company { ID = 49, Name = "JP Morgan & Chase & Co", Price = 45.73, Change = 0.07, PctChange = 0.15, LastChange = today },
                new Company { ID = 50, Name = "McDonald\"s Corporation", Price = 36.76, Change = 0.86, PctChange = 2.40, LastChange = today },
                new Company { ID = 51, Name = "Merck & Co., Inc.", Price = 40.96, Change = 0.41, PctChange = 1.01, LastChange = today },
                new Company { ID = 52, Name = "Microsoft Corporation", Price = 25.84, Change = 0.14, PctChange = 0.54, LastChange = today },
                new Company { ID = 53, Name = "Pfizer Inc", Price = 27.96, Change = 0.4, PctChange = 1.45, LastChange = today },
                new Company { ID = 54, Name = "The Coca-Cola Company", Price = 45.07, Change = 0.26, PctChange = 0.58, LastChange = today },
                new Company { ID = 55, Name = "The Home Depot, Inc.", Price = 34.64, Change = 0.35, PctChange = 1.02, LastChange = today },
                new Company { ID = 56, Name = "The Procter & Gamble Company", Price = 61.91, Change = 0.01, PctChange = 0.02, LastChange = today },
                new Company { ID = 57, Name = "United Technologies Corporation", Price = 63.26, Change = 0.55, PctChange = 0.88, LastChange = today },
                new Company { ID = 58, Name = "Verizon Communications", Price = 35.57, Change = 0.39, PctChange = 1.11, LastChange = today },
                new Company { ID = 59, Name = "Wal-Mart Stores, Inc.", Price = 45.45, Change = 0.73, PctChange = 1.63, LastChange = today }
            };
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Cell Editing - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />   
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <h1>Cell Editing Grid Example</h1>
    
        <p>This example shows how to enable users to edit the contents of a grid.</p>
    
        <ext:GridPanel
            runat="server"
            Width="600"
            Height="300"
            Title="Edit Plants?"
            Frame="true"
             LeadingBufferZone="10"
            >
            <Store>
                <ext:Store runat="server" ID="Store1">
                    <Model>
                        <ext:Model runat="server" Name="Plant">
                            <Fields>
                                <ext:ModelField Name="Name" Type="String" />
                                <ext:ModelField Name="price" Type="Float" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column
                        runat="server"
                        Text="Common Name"
                        DataIndex="Name"
                        Flex="1">
                    </ext:Column>
    
                    <ext:Column
                        runat="server"
                        Text="Price"
                        DataIndex="Price"
                        Width="70"
                        Align="right">
                        <Renderer Format="UsMoney" />
                        <Editor>
                            <ext:NumberField runat="server" AllowBlank="false" MinValue="0" MaxValue="100000">
                            </ext:NumberField>
                        </Editor>
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <Plugins>
                <ext:CellEditing runat="server" ClicksToEdit="1" />
            </Plugins>
        </ext:GridPanel>
    </body>
    </html>

    I came up with the following javascript override that helps but doesn't completely prevent the issue. I can still get the issue after using this override, but only if I just hold down tab -- and then it appears to just be a timing issue. This override isn't thoroughly tested and could have unintended consequences on other behavior.

    /* overriding getPosition so that it returns the position without updating the scroller's
            position property, and it leaves the scroller as dirty.  This is important because
            the scroll handler that picks up on this event is expecting the scroller position to not be updated--
           this is needed because of the odd case that the grid was scrolled because an editor was brought into focus
            */
    	    Ext.override(Ext.scroll.Scroller, {
    	        getPosition: function () {
    	            var me = this,
                    element = me.getScrollElement(),
                        elScroll,
                       newPos = Ext.clone(me.position);
    
    	            if (element && !element.destroyed) {
    	                elScroll = me.getElementScroll(element);
    	                newPos.x = elScroll.left;
    	                newPos.y = elScroll.top;
    	            }
    
    	            return newPos;
    	        }
    	    });
    Last edited by fabricio.murta; Aug 17, 2017 at 8:12 PM.
  2. #2
    Hello @tylert!

    By chance I had an Ext.NET 4.2.2 project set up here and I could reproduce the issue you have mentioned.

    But thing is, we've released Ext.NET 4.3.0, which no matter how I tried, I couldn't reproduce it. So well, I suggest you perform the NuGet package upgrade on your project like I did to mine. :) Of course, as soon as I upgraded the NuGet package in my project and ran the example, the issue was no longer reproducible. I could either scroll bit by bit, or keep the <tab> key pressed, and it went down smoothly to the end of the grid. Well, and only then back up.

    At first, I could notice any issue with that. So I'm pretty confident you are one upgrade away from fixing this issue.

    Oh, I didn't even try adding the override block you shared above, I believe it is completely unnecessary now.

    Hope this helps! Your feedback would be very appreciated.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    I've confirmed that this issue is fixed in 4.3.0 for my test case. Thanks!
  4. #4
    Hello @tylert!

    Thanks for the feedback, and glad the issue is really no more for you!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 5
    Last Post: Sep 20, 2017, 12:23 AM
  2. Replies: 2
    Last Post: Oct 15, 2015, 4:56 AM
  3. [CLOSED] GridPanel Column Renderer issue
    By vadym.f in forum 3.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 07, 2015, 12:27 PM
  4. [CLOSED] Tree Panel and Buffered Renderer
    By CanopiusApplications in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 11, 2014, 12:04 PM

Posting Permissions