PDA

View Full Version : How to transform grid info to comboBox



lightyear416
9 Jun 2011, 5:49 PM
Hi,guys!

I need to click on line in grid and show info into the Formpanel,the example writing by itself I have learned.However,I still don't know how to take it between gird and comboBox.For example,When the grid info below header sex is man,how to show it on comboBox in Formpanel when I click.Thanks

skirtle
10 Jun 2011, 8:41 PM
new Ext.grid.GridPanel({
autoExpandColumn: '0',
height: 200,
renderTo: Ext.getBody(),
width: 400,
columns: [
{dataIndex: 'name', header: 'Name'},
{
dataIndex: 'sex',
header: 'Sex',
renderer: function(val) {
return val === 'M' ? 'Male' : 'Female';
}
},
{dataIndex: 'age', header: 'Age'}
],
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners: {
rowselect: function(selModel, index, record) {
// Equivalent to calling setValue() on each field
formPanel.getForm().loadRecord(record)
}
}
}),
store: new Ext.data.ArrayStore({
fields: ['name', 'sex', 'age'],
data: [
['Tom', 'M', 12],
['Sam', 'F', 24],
['Cat', 'F', 36]
]
})
});

var formPanel = new Ext.form.FormPanel({
height: 200,
renderTo: Ext.getBody(),
width: 400,
items: [
{fieldLabel: 'Name', name: 'name', xtype: 'textfield'},
{
editable: false,
fieldLabel: 'Sex',
forceSelection: true,
name: 'sex',
store: [['M', 'Male'], ['F', 'Female']],
triggerAction: 'all',
xtype: 'combo'
},
{fieldLabel: 'Age', name: 'age', xtype: 'numberfield'}
]
});

lightyear416
13 Jun 2011, 5:02 PM
Thank strike's answer.The key is name must match,I learn from your code.Thank you again