How to set an extjs grid record phantom to true

In Ext 4.1, I am dropping items to a grid, but the records come in with an id and the phantom flag is set to false, causing the store to remain empty and not add those records to it. even though they appear fine on the grid.

I read several solutions online, and many suggested setting the phantom flag to false and/or setting the id to null, but I am not able to implement this? Where do I set it?

Here are related links:

  • http://www.sencha.com/forum/showthread.php?261174-Store-is-not-syncing-after-adding-new-row-to-grid-(CRUD)
  • http://yiyujia.blogspot.com/2011/06/managing-grid-crud-in-extjs-4.html
  • http://www.sencha.com/forum/showthread.php?143710-Grid-Drag-amp-Drop-and-Getting-dropped-records
  • I tried adding a beforedrop listener on the viewConfig and changing the phantom flag and id there, but that didnot work. Any help?


    I have it working. Try this:

    // BUGFIX - when records are copied between grids, the copied record don't get its phantom set
    // to true, thus, no Create call will be made to the server.
    Ext.override( Ext.data.Model, {
    
        copy : function(newId) {
            var iNewRecord = this.callParent( arguments );
            iNewRecord.phantom = true;
            return iNewRecord;    
        }
    });
    

    I also have my source table with the view config copy set to true, although at the time of writing I have no idea why or whether this even does anything:

    Ext.define('BS.view.items.Items' ,
    {
        extend: 'BS.tree.Panel',
    
        ...
    
        viewConfig: {
            plugins: {
                ptype: 'treeviewdragdrop',
                dragGroup: 'classrooms',
            },
    
            // notice this
            copy: true            
        },
    
    });
    
    链接地址: http://www.djcxy.com/p/67644.html

    上一篇: 如何在extjs中正确地将rowediting和rowexpander结合在一起?

    下一篇: 如何设置extjs网格记录幻像为真