extjs 嵌套数据网格过滤器和重新加载在 viewModel 上不起作用
Posted
技术标签:
【中文标题】extjs 嵌套数据网格过滤器和重新加载在 viewModel 上不起作用【英文标题】:extjs nested data grid filter and reload not working on viewModel 【发布时间】:2016-11-06 17:35:52 【问题描述】:为什么不工作过滤器并重新加载存储网格... 数据是嵌套的.. 我希望父母使用代理模型..
嵌套数据 json
服务器 ssssssss s s s s
"success": true,
"data":
"taksitler": [
"taksit_id": "13",
"mebla": "100.00",
"tarih": "2016-10-31",
"odeme": "1"
,
"taksit_id": "14",
"mebla": "150.00",
"tarih": "2016-10-31",
"odeme": "0"
,
"taksit_id": "15",
"mebla": "16.00",
"tarih": "2016-10-31",
"odeme": "0"
,
"taksit_id": "16",
"mebla": "14.00",
"tarih": "2016-10-31",
"odeme": "0"
,
"taksit_id": "17",
"mebla": "20.00",
"tarih": "2016-10-31",
"odeme": "0"
]
model.plan.Plan
Ext.define('Rent.model.plan.Plan',
extend: 'Ext.data.Model',
proxy:
type: 'ajax',
idParam: 'plan_id',
api:
create: 'bayi/plan/create',
read: 'bayi/plan/read',
update: 'bayi/plan/update',
destroy: 'bayi/plan/destroy',
,
reader:
type:'json',
rootProperty: 'data'
,
writer:
encode: true,
writeAllFields: true,
rootProperty: 'data',
allDataOptions:
associated: true
,
,
fields: [
name: 'plan_id', type: 'int',
name: 'fatura_id', type: 'int',
name: 'hesap_id', type: 'int',
],
hasMany:
model: 'Rent.model.plan.Taksitler',
name:'taksitler',
associationKey:'taksitler'
);
model.plan.Taksitler
Ext.define('Rent.model.plan.Taksitler',
extend: 'Ext.data.Model',
fields: [
name: 'taksit_id', type: 'int',
name: 'mebla', type: 'number',
name: 'tarih', type: 'date', dateWriteFormat: 'Y-m-d',
name: 'odeme', type: 'boolean', defaultValue: false
],
);
store.plan.taksitler
Ext.define('Rent.store.plan.Taksitler',
extend: 'Ext.data.Store',
alias: 'store.taksitler',
model : 'Rent.model.plan.Taksitler',
pageSize: 0,
);
store.plan.Plan
Ext.define('Rent.store.plan.Plan',
extend: 'Ext.data.Store',
alias: 'store.plan',
model : 'Rent.model.plan.Plan',
pageSize: 0,
);
网格
Ext.define('Rent.view.odemeplani.OdemePlani',
extend: 'Ext.window.Window',
defaultListenerScope: true,
viewModel: true,
items: [
xtype: 'gridpanel',
bind:
store: 'plan.taksitler'
,
columns: [
text: 'ID',
dataIndex: 'taksit_id',
hidden: true
,
xtype: 'numbercolumn',
text: 'Mebla',
dataIndex: 'mebla',
format: '0.00',
flex: 4,
resizable: false,
sortable: false,
,
xtype: 'datecolumn',
text: 'Tarih',
dataIndex: 'tarih',
format: 'd.m.Y',
flex: 4,
resizable: false,
,
xtype: 'booleancolumn',
text: 'Ödeme',
dataIndex: 'odeme',
trueText: 'Yapıldı',
falseText: 'Yapılmadı'
],
],
tbar: [
text: 'Yenile',
iconCls: 'icon-yenile-16',
handler: 'yenile'
,
],
// events
yenile: function()
this.down('grid').store.reload();
// fail :
// GET http://localhost/Rent.model.plan.Taksitler?_dc=1467681109503
// 404 (Not Found) ???? Why doesn't parent's proxy
,
// ~ events
constructor: function(config)
this.callParent(arguments);
this.getViewModel().linkTo('plan',
type: 'Rent.model.plan.Plan',
id: config.id
);
,
);
【问题讨论】:
【参考方案1】:你应该把数组直接放在data中,因为你声明它是root,所以json应该是这样的:
JSON:
"success": true,
"data": [
"taksit_id": "13",
"mebla": "100.00",
"tarih": "2016-10-31",
"odeme": "1"
,
"taksit_id": "14",
"mebla": "150.00",
"tarih": "2016-10-31",
"odeme": "0"
,
"taksit_id": "15",
"mebla": "16.00",
"tarih": "2016-10-31",
"odeme": "0"
,
"taksit_id": "16",
"mebla": "14.00",
"tarih": "2016-10-31",
"odeme": "0"
,
"taksit_id": "17",
"mebla": "20.00",
"tarih": "2016-10-31",
"odeme": "0"
]
【讨论】:
我的 json 数据正常工作。 ..我想使用父母代理。 .. yenile: function() this.down('grid').store.reload(); // 失败 : // GET localhost/Rent.model.plan.Taksitler?_dc=1467681109503 // 404(未找到)????为什么没有父母的代理,以上是关于extjs 嵌套数据网格过滤器和重新加载在 viewModel 上不起作用的主要内容,如果未能解决你的问题,请参考以下文章
如何在具有嵌套数据的网格中设置组合框值? Extjs 4.2 Mvc
当我重新加载网格和存储时,extjs 缓存具有相同名称的图片