[CLOSED] 2.3 GridPanel Locked Column Editor with plugin CellEditing can't edit on current column position

  1. #1

    [CLOSED] 2.3 GridPanel Locked Column Editor with plugin CellEditing can't edit on current column position

    Please run below code, when click on column A (data 1,2,3), the editor will appear on column B

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store1.Data = new List<object>()
                {
                    new {ID=1,A="1",B="11",C="111"},
                    new {ID=2,A="2",B="22",C="222"},
                    new {ID=3,A="3",B="33",C="333"}
                };
                Store1.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>
        <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
            <Items>
                <ext:GridPanel runat="server">
                    <Store>
                        <ext:Store ID="Store1" runat="server">
                            <Model>
                                <ext:Model runat="server" IDProperty="ID">
                                    <Fields>
                                        <ext:ModelField Name="ID" />
                                        <ext:ModelField Name="A" />
                                        <ext:ModelField Name="B" />
                                        <ext:ModelField Name="C" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel>
                        <Columns>
                            <ext:Column ID="Column1" runat="server" DataIndex="A" Text="A" Locked="true">
                                <Editor>
                                    <ext:TextField ID="TextField1" runat="server" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ID="Column2" runat="server" DataIndex="B" Text="B" Locked="false">
                                <Editor>
                                    <ext:TextField ID="TextField2" runat="server" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ID="Column3" runat="server" DataIndex="C" Text="C" Locked="false">
                                <Editor>
                                    <ext:TextField ID="TextField3" runat="server" />
                                </Editor>
                            </ext:Column>
                        </Columns>
                    </ColumnModel>
                    <Plugins>
                        <ext:CellEditing ID="CellEditing1" runat="server"></ext:CellEditing>
                    </Plugins>
                </ext:GridPanel>
            </Items>
        </ext:Viewport>
    </body>
    </html>
    Last edited by Daniil; Oct 28, 2013 at 3:20 PM. Reason: [CLOSED]
  2. #2
    Hi @devil,

    Thank you for the report. It is a known problem.
    https://github.com/extnet/Ext.NET/issues/354

    Unfortunately, we have no solution at the moment.
  3. #3
    Please try the following fix.

    Fix
    Ext.grid.plugin.CellEditing.override({
        showEditor: function(ed, context, value) {
            var me = this,
                record = context.record,
                columnHeader = context.column,
                sm = me.grid.getSelectionModel(),
                selection = sm.getCurrentPosition(me.grid.view),
                otherView = selection && selection.view;
    
            // Selection is for another view.
            // This can happen in a lockable grid where there are two grids, each with a separate Editing plugin
            if (otherView && otherView !== me.view) {
                return me.lockingPartner.showEditor(ed, me.lockingPartner.getEditingContext(selection.record, selection.columnHeader), value);
            }
    
            me.setEditingContext(context);
            me.setActiveEditor(ed);
            me.setActiveRecord(record);
            me.setActiveColumn(columnHeader);
    
            // Select cell on edit only if it's not the currently selected cell
            if (sm.selectByPosition && (!selection || selection.column !== context.colIdx || selection.row !== context.rowIdx)) {
                if (!sm.isCellModel && sm.select) {
                    sm.select(record);
                }
                else {
                    sm.selectByPosition({
                        row: context.rowIdx,
                        column: context.colIdx,
                        view: me.view
                    });
                }
            }
    
            ed.startEdit(me.getCell(record, columnHeader), value, context);
            me.editing = true;
            me.scroll = me.view.el.getScroll();
        }
    });
    
    Ext.selection.RowModel.override({
        getCurrentPosition: function(view) {
            var firstSelection = this.selected.items[0];
            if (firstSelection) {
                return new Ext.grid.CellContext(view || this.view).setPosition(this.store.indexOf(firstSelection), 0);
            }
        }
    });
  4. #4
    I "solved" a similar issue by using the CellSelectionModel.
  5. #5
    Yep, a good solution unless you need to use a Row and Checkbox selection models:)

    Anyway, thank you for sharing that!
  6. #6
    It has been fixed in the revision #5729. It goes to the v2.5.1 release.
  7. #7
    Thank you!
    Last edited by geoffrey.mcgill; Apr 26, 2016 at 1:16 AM.

Similar Threads

  1. Replies: 3
    Last Post: Sep 29, 2014, 3:43 PM
  2. Replies: 6
    Last Post: Jun 21, 2013, 3:59 PM
  3. Replies: 6
    Last Post: Jun 20, 2013, 1:25 PM
  4. Replies: 1
    Last Post: Feb 19, 2012, 1:07 PM
  5. [CLOSED] Edit current record in a Column-Editor.
    By macap in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 04, 2009, 3:57 PM

Tags for this Thread

Posting Permissions