ExtJs 编辑器网格面板的问题

发布于 2024-12-01 16:20:00 字数 1013 浏览 1 评论 0原文

我有一个绑定到商店的 extjs 编辑器网格面板(3.3.1)。新记录通过顶部的空行添加到网格中。在商店的负载上,我在网格顶部添加一个空行。当用户添加新值并且焦点丢失时,我将添加另一个空行。

AV.ClassifiedCategories = Ext.extend(Ext.grid.EditorGridPanel, {
   ....

initComponent: function(){  

    this.store = this.initialConfig.store;

            //add an empty row at top
    this.store.on('load', this.addCategory, this);

            Ext.apply(this, 
    {
        clicksToEdit: 1,            
        listeners:
        {
        afteredit : function(e){
                 this.addCategory();                        
        },
        scope: this
        }
    });
    },

    //adds an empty row and insert a record to store
    addCategory: function(){
    var Category = this.getStore().recordType;
    var cat = new Category({ cat_id: null, cat_name: "" });     

    this.stopEditing();     
    this.store.insert(0, cat);  
    this.startEditing(0, 0);

    return cat;
},

    ...
});

这里面临的问题是,一旦触发 afteredit 事件并添加空行,焦点就不会移动到第一行,即第二行仍处于编辑模式。我该如何解决这个问题?

I've an extjs editor grid panel(3.3.1) that is binded to a store. New records are added to the grid by an empty row at the top. On the load of the store I'm adding an empty row at the top of the grids. When the user adds a new value and the focus loses out I'm adding another empty row.

AV.ClassifiedCategories = Ext.extend(Ext.grid.EditorGridPanel, {
   ....

initComponent: function(){  

    this.store = this.initialConfig.store;

            //add an empty row at top
    this.store.on('load', this.addCategory, this);

            Ext.apply(this, 
    {
        clicksToEdit: 1,            
        listeners:
        {
        afteredit : function(e){
                 this.addCategory();                        
        },
        scope: this
        }
    });
    },

    //adds an empty row and insert a record to store
    addCategory: function(){
    var Category = this.getStore().recordType;
    var cat = new Category({ cat_id: null, cat_name: "" });     

    this.stopEditing();     
    this.store.insert(0, cat);  
    this.startEditing(0, 0);

    return cat;
},

    ...
});

The problem is facing here is once the afteredit event is fired and an empty row is added the focus is not moving to the first row i.e. the second row is still in edit mode. How I can solve that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迟月 2024-12-08 16:20:00

我已经使用了您的代码并创建了此演示。正如您所看到的,一切都按预期进行。您确定已向我们提供了无法运行的代码吗?

I've taken your code and have created this demo. As you can see everything works as expected. Are you sure you have provided us with non-working code?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文