【问题标题】:ExtJS : move a record in a gridExtJS:在网格中移动记录
【发布时间】:2014-04-11 07:13:36
【问题描述】:

我在 ExtJS 上有一个简单的网格,希望用户能够将记录从其原始位置移动。 当用户双击记录时,会出现一个包含组合框的小窗口,他可以在组合框上选择一个值,然后单击保存按钮以应用更改。 但是,它不起作用,我在不同的论坛上为此搜索了许多解决方案,但似乎都没有。要么什么都没有发生,要么在网格的末尾添加了一个未定义的行。这是我使用的基本代码:

onEditRank: function(view, cell, cellIndex, record, row, rowIndex, e)
        {
            var reditor = Ext.create('CMS.view.Views.RankEditor', {id: 'reditorView'});
            var form = reditor.down('form');
            var oldPos = this.getFlatrq().getView().indexOf(record);
            var grStore = this.getGridRnkStoreStore();

            var i;
            var data = [];
            for(i = 1; i <= CMS.global.Variables.limit + 1; i++)
            {
                data.push(i);
            }

            var combo = Ext.create
            (
                'Ext.form.field.ComboBox',
                {
                    fieldLabel: 'Rank',
                    itemId: 'cmbRank',
                    store: data
                }
            );
            var saveRnk = Ext.create
            (
                'Ext.button.Button',
                {
                    text: 'Save',
                    handler: function()
                    {
                    }
                }
            );
            form.add(combo);
            form.add(saveRnk);

            reditor.show();
        }

现在这里是我为保存按钮尝试过的不同处理程序:

handler: function()
{
   grStore.remove(record);
   grStore.insert(record, combo.getValue() - 1);


   this.up('form').up('window').close();
}

handler: function()
{
   grStore.removeAt(oldPos);
   grStore.insert(record, combo.getValue() - 1);
   this.up('form').up('window').close();
}

handler: function()
{
   var rec = grStore.getAt(oldPos).copy();
   grStore.removeAt(oldPos);
   grStore.insert(rec, combo.getValue() - 1);
   this.up('form').up('window').close();
}

这 3 个处理程序在我的网格末尾插入了未定义的行。我显示了 oldPos 和 combo.getValue() 的值,它们是正确的,我还显示了删除前后的记录变量,因为我认为它可能会被破坏,但事实并非如此。我还尝试添加一个移动功能来存储和调用它:

'CMS.store.GridRnkStore', 
    {
        extend: 'Ext.data.Store',
        model: 'CMS.model.GridRnkModel',
        autoLoad: false,
        filterOnLoad: true,
        autoSync: true,
        move: function(from, to)
        {
            console.log(from + " " + to);
            var r = this.getAt(from);
            this.data.removeAt(from);
            this.data.insert(to, r);
            this.fireEvent("move", this, from, to);
        },

    }
);

但它也不起作用,实际上什么也没做(我在 move 函数中放置了一些 console.log 以查看它是否被调用,并且使用正确的参数)。我的想法不多了,任何帮助将不胜感激。 谢谢。

【问题讨论】:

  • 您是否刷新了网格视图?也许它已被删除但视图没有刷新。

标签: grid extjs4 record move


【解决方案1】:

尝试将私有move参数设置为truetrue

remove: function(records, /* private */ isMove, silent)

【讨论】:

  • 这很好,我不知道这个 remove 原型,但是它仍然失败......我仍然在我的网格末端得到一个未定义的行。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多