在 Ext 4.1 中,我将项目放入网格中,但记录带有 id,且幻像标志设置为 false,导致存储保持为空并且不会将这些记录添加到其中。即使它们在网格上看起来很好。
我在线阅读了几个解决方案,许多人建议将 phantom 标志设置为 false 和/或将 id 设置为 null,但我无法实现这一点?在哪里设置?
以下是相关链接:
- 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
我尝试在 viewConfig 上添加一个 beforedrop
监听器并更改其中的幻像标志和 id,但这不起作用。有什么帮助吗?
最佳答案
我已经可以正常工作了。试试这个:
// 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;
}
});
我的源表的 View 配置copy
设置为true,尽管在撰写本文时我不知道为什么或者这是否有任何作用:
Ext.define('BS.view.items.Items' ,
{
extend: 'BS.tree.Panel',
...
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
dragGroup: 'classrooms',
},
// notice this
copy: true
},
});
关于javascript - 如何将 extjs 网格记录幻像设置为 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16724129/