U.P*_*U.P 1 javascript extjs extjs6-classic
我正在努力学习ExtJS,并且有点卡在一个地方.我想创建一个屏幕,顶部有一个网格,底部有一个表格.我想将它们彼此绑定,以便当我从Grid中选择一行时,填充表单字段(在网格中使用相同的记录),当我更改网格或表单中的任何内容时,另一面会更新.
到目前为止,我有一个网格和表格的视图.我有一个为网格提供数据的商店.我被困在这里.如何在表单和网格之间进行双向绑定.我试过谷歌,在这里和这里找到了一些样本,但它们都是单向绑定.即如果我在网格上执行以下操作:
listeners: {
selectionchange: function(model, records) {
var rec = records[0];
var form = Ext.getCmp('chartofaccountsForm');
form.loadRecord(rec);
}
}
Run Code Online (Sandbox Code Playgroud)
它只填充当前所选记录的表单,但是当我更新表单中的记录时,网格不会更新.
有人能指点我正确的方向来帮助我吗?任何教程或博客文章都会非常有用
试试这个例子:
Ext.widget('container',{
width: 600,
hight: 800,
renderTo: Ext.getBody(),
viewModel: {
formulas: {
selection: {
bind: '{g.selection}',
get: function(selection){
return selection;
}
}
}
},
items: [
{
xtype: 'grid',
title: 'Grid',
reference: 'g',
store: {
type: 'store',
fields: ['id', 'name'],
data: [{id: 1, name: 'foo'}, {id: 2, name: 'bar'}]
},
columns: [
{dataIndex: 'id', header: 'ID'},
{dataIndex: 'name', header: 'Name'}
]
},
{
xtype: 'form',
title: 'Form',
items: [
{
xtype: 'displayfield',
fieldLabel: 'ID',
bind: '{selection.id}'
},
{
xtype: 'textfield',
fieldLabel: 'Name',
bind: '{selection.name}'
}
],
bind: {
hidden: '{!selection}'
}
}
]
});
Run Code Online (Sandbox Code Playgroud)
https://fiddle.sencha.com/#fiddle/179d
归档时间: |
|
查看次数: |
1995 次 |
最近记录: |