Extjs中我用data.jsonStore从后台获取数据后.前台再往里面添加一条数据.

2025-04-19 07:14:24
推荐回答(1个)
回答(1):

//定义类型,注意和你json返回的记录格式要一致
var MyRecordType = Ext.data.Record.create
([
{name: "id", type: "int"},
{name: "name", type: "string"}
]);
//要添加的记录
var oneRecord = new RecordType
({
id: 0,
name: "张三"
});
//Store
var userStore = new Ext.data.Store({
//此处省略
})

userStore.load();
userStore.add(oneRecord);