extjs - 添加新行或编辑现有行时行编辑插件的奇怪行为
问题描述
第一次添加新行或编辑现有行时(在渲染组件之后),Rowediting 插件出现奇怪的行为:编辑器大小不正确和按钮偏离中心。它是一个错误吗?如果它是一个错误,有没有解决这个问题的方法?
分机 JS 6.7.0
解决方案
我曾经遇到过这个问题,虽然我没有详细的答案,但我有几个解决方案。
当您使用带有inline data
(未定义适当的 Ext.data.Model)的商店,并且您正在添加以Ext.data.Model
.
所以这里有两个解决方案:
第一个解决方案:添加内联数据
您无需添加 的实例Ext.data.Model
,而是添加带有必填字段的简单 json 数据。
// in your handler...
// create the record as json
jsonRecord = {
name: '',
email: '',
phone: ''
}
// Adding to the store converts the json data into records
const addedRecords = store.add(jsonRecord);
// Since we are only adding a single record, we edit the idx 0
rowediting.startEdit(addedRecords[0]);
第二种解决方案:为您的数据定义模型
Ext.define('YourModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'email', type: 'string'},
{name: 'phone', type: 'string'}
]
});
并使用此模型创建您的商店...
Ext.create('Ext.data.Store', {
storeId: 'simpsonsStore',
model: 'YourModel', // Set model here
// fields:[ 'name', 'email', 'phone'],
data: [
{ name: 'Lisa', email: 'lisa@simpsons.com', phone: '555-111-1224' },
{ name: 'Bart', email: 'bart@simpsons.com', phone: '555-222-1234' },
{ name: 'Homer', email: 'homer@simpsons.com', phone: '555-222-1244' },
{ name: 'Marge', email: 'marge@simpsons.com', phone: '555-222-1254' }
]
});
...并创建新记录。
// In your handler
// Create the record with your model
record = Ext.create('YourModel');
// Add to the store
store.add(record);
// Edit the record instance
rowediting.startEdit(record);
在这两种方法中,更新行也会更新新添加的记录。
希望这可以帮助
推荐阅读
- r - 根据列数替换值 R
- reactjs - 组件异常:未定义不是对象(评估'board[rowSet][colSet]')
- javascript - 保护 Instagram 的客户端访问令牌
- url - 将数据从一个电子表格复制到另一个但
- python - 在 Pydantic BaseModel 类中实例化后更改字段
- swift - 整个列表是可按下的,而不是按钮本身
- php - 在 CodeIgniter 4 中验证多个输入
- java - ImageIO 读取 gif 并写入其他文件
- python - Windows Python:sphinx-build.exe 文件“消失”
- android - 无法使用 kotlin 多平台启动前台服务