2016-02-12 59 views

回答

3

您可能能够将您的文本框(在你的列标题的项目文本字段)的值配置绑定到一个属性一个视图模型。

喜欢的东西:

var vm = Ext.create('Ext.app.ViewModel', { 

    data: [{ 
     test : '' 
    }], 

    alias: 'viewmodel.myviewmodel', 

    stores: { 
     simpsonsStore: Ext.create('Ext.data.Store', { 
      fields:['name', 'email', 'phone'], 
      data:[ 
       {'name': 'Lisa', "email":"[email protected]", "phone":"555-111-1224"}, 
       {'name': 'Bart', "email":"[email protected]", "phone":"555-222-1234"}, 
       {'name': 'Homer', "email":"[email protected]", "phone":"555-222-1244"}, 
       {'name': 'Marge', "email":"[email protected]", "phone":"555-222-1254"} 
      ] 
     }) 
    } 
}); 

var grid = Ext.create('Ext.panel.Panel', { 
    height: 400, 
    width: 400, 
    renderTo: Ext.getBody(), 
    viewModel: vm, 
    layout: 'hbox', 

    items:[{ 
     xtype: 'button', 
     bind: { 
      text: '{test}' 
     } 
    },{ 
     xtype: 'grid', 
     flex: 1, 
     bind: '{simpsonsStore}', 
     columns: [{ 
      text: 'Name', 
      dataIndex: 'name', 
      items: [{ 
       xtype: 'textfield', 
       bind: { 
        value: '{test}' 
       } 
      }] 
     }, { 
      text: 'Email', 
      dataIndex: 'email', 
      flex: 1 
     }, { 
      text: 'Phone', 
      dataIndex: 'phone' 
     }] 
    }] 
}); 

PS:这里是小提琴)https://fiddle.sencha.com/#fiddle/15j6,你可以输入你的头提起,按钮上的文字会自动更新:)

+0

非常有用的,谢谢。 –