[英]ExtJS - Saving nested data to .json file
我創建了一個商店,在這里從.json文件加載嵌套數據:
var userStore = Ext.create('Ext.data.Store', {
model: 'User',
storeId:'2013',
autoLoad: true,
pageSize: 4,
proxy: {
type: 'ajax',
url: 'data/users.json',
reader: {
type: 'json',
root: 'users',
totalProperty: 'total'
},
writer: {
type: 'json'
}
}
});
要將任何新數據添加到網格,請使用:
var asdfg = Ext.getStore(myNewGrid);
asdfg.add({lastname: nowa, firstname: nowa2);
一切正常,直到刷新頁面。 之后,我將丟失所有更改。
我的模型“用戶”文件:
Ext.define('MyApp.controller.Users', {
extend: 'Ext.app.Controller',
border: false,
views: [
'user.List'
],
init: function() {
this.control({
'viewport > panel': {
render: this.onPanelRendered
}
});
},
onPanelRendered: function() {
console.log('The panel was rendered');
}});
有什么簡單的方法可以保存和提交類似於加載的新更改? 要開始我的網站,請使用Sencha Cmd v.4.0.4
只需在商店中使用autoSync:true
。
在這種情況下,向您的代理添加type:rest
會更容易。
看這個例子: http : //dev.sencha.com/deploy/ext-4.0.1/examples/restful/restful.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.