[CLOSED] Focus Problem in EditableGrid Plugin

  1. #1

    [CLOSED] Focus Problem in EditableGrid Plugin

    Hi,

    in your EditableGrid Plugin example page there is a problem.
    If i edit the first row , lets say i change the Value field "1" to "12" then click the second column "One" that is the second column "Text", it won't focus on it. I have to click twice.
    The problem appears only if i change a value then click onther column value on the same row.
    That's the same with the Tab key, i have to press 4 times to focus to the next field.

    Thanks and best regards.
    Last edited by Daniil; Jan 20, 2011 at 9:47 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Confirmed. I have reproduced the issue.

    The problem - row is refreshed after editor's blur with new value. Refreshing of row causes re-rendering of editors. To be brief, event is "lost" during these actions.

    Maybe, would be best to report this issue to EditableGrid's creators on sencha forum.

    For now, I can suggest the following workaround for mouse clicking.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.GridPanel1.Store.Primary.DataSource = new List<object>
                {
                    new { 
                        Value = 1, 
                        Text = "One"
                    },
                    new { 
                        Value = 2, 
                        Text = "Two"
                    },
                    new { 
                        Value = 3, 
                        Text = "Three"
                    },
                    new { 
                        Value = 4, 
                        Text = "Four"
                    },
                    new { 
                        Value = 5, 
                        Text = "Five"
                    }
                };
    
                this.GridPanel1.Store.Primary.DataBind();
            }
        }
    </script>
    
    <!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>GridPanel with EditableGrid Plugin - Ext.NET Examples</title>
    
        <script type="text/javascript">
            var mouseDownFlag = {};
    
            var rowUpdatedHandler = function (item, rowIndex, record) {
                if (!Ext.isEmpty(mouseDownFlag) && (mouseDownFlag.row === rowIndex)) {
                    this.editors[mouseDownFlag.row][mouseDownFlag.col].focus(false, 10);
                    mouseDownFlag = {};
                }
            }
            var editorRenderHandler = function (editor) {
                editor.el.on('mousedown', function(e) {
                    mouseDownFlag.row = editor.grid.row;
                    mouseDownFlag.col = editor.grid.col;
                });
            }
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel 
            ID="GridPanel1" 
            runat="server" 
            Width="300" 
            Height="200" 
            Title="EditableGrid Plugin">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:JsonReader>
                            <Fields>
                                <ext:RecordField Name="Value" Type="Int" />
                                <ext:RecordField Name="Text" Type="String" />
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
            </Store>
            <Plugins>
                <ext:EditableGrid runat="server" />
            </Plugins>
            <ColumnModel>
                <Columns>
                    <ext:RowNumbererColumn />
                    <ext:Column 
                        Header="Value" 
                        DataIndex="Value"
                        Width="130" 
                        Sortable="true">
                        <Editor>
                            <ext:NumberField runat="server" AllowBlank="false">
                                <Listeners>
                                    <Render Handler="editorRenderHandler(this);" />
                                    <Focus Handler="mouseDownFlag = {};" />
                                </Listeners>
                            </ext:NumberField>
                        </Editor>
                    </ext:Column>
                    <ext:Column 
                        Header="Text" 
                        DataIndex="Text" 
                        Width="130"
                        Sortable="true">
                        <Editor>
                            <ext:TextField ID="TextField1" runat="server" AllowBlank="false">
                                <Listeners>
                                    <Render Handler="editorRenderHandler(this);" />
                                    <Focus Handler="mouseDownFlag = {};" />
                                </Listeners>
                            </ext:TextField>
                        </Editor>
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <View>
                <ext:GridView runat="server">
                    <Listeners>
                        <RowUpdated Fn="rowUpdatedHandler" Delay="1" />
                    </Listeners>
                </ext:GridView>
            </View>
        </ext:GridPanel>
        </form>
    </body>
    </html>
  3. #3
    for the other controls (like DateField and Combobox), it does not work.
  4. #4
    Confirmed. We are investigating. Not sure there is a clear solution that covers all cases.
  5. #5
    Hi,

    We have added a fix. Please update from SVN to revision #3414 and test.

    Note.
    That still doesn't work in the following case.

    1. Some cell is edited
    2. Clicking on trigger of field (ComboBox, DateField) in another cell of the same row
    3. This field won't be focused

    We have no solution for this case at the moment.

    Generally speaking, EditableGrid is just plugin, not pure ExtJS. And this plugin makes grid non-standard grid. So, there can be issues.

Similar Threads

  1. EditableGrid focus Problem?
    By zyyjc in forum 1.x Help
    Replies: 0
    Last Post: May 25, 2012, 1:00 PM
  2. Replies: 0
    Last Post: Jan 10, 2012, 8:47 AM
  3. Replies: 3
    Last Post: Dec 01, 2011, 12:47 PM
  4. [CLOSED] EditableGrid Plugin - Problem using Tab key
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 09, 2010, 1:59 PM
  5. EditableGrid - Tab Focus
    By shankar in forum 1.x Help
    Replies: 1
    Last Post: Aug 06, 2010, 5:40 PM

Tags for this Thread

Posting Permissions