I am working on an application where i use a grid and have a combobox outside the grid whose selections are based on the selected rows within the grid.
Basically the content of the combobox is dynamically updated based on the selection of rows.
1)when the application first load, Just selcet the grid item (2-- 12343ddw3e) or(1--12343),
the combobox Machine just show the value but not the displayField。but what I want is the displayfield is show and the the value is hidden.
1.png
2)when click the combobox,it show correctly。
2.png
3)and now ,select the grid item,the combox “Machine Type ” is show correctly.
3.png
4.png
Code:
//case_mtstore Ext.define('case_mtData', {
extend: 'Ext.data.Model',
fields: ['name','id'] //modify
});
var case_mtstore = Ext.create('Ext.data.Store', {
model: 'case_mtData',
autoLoad: false,
proxy: {
type: 'jsonp',
url: './phps/queryall-mt.php',
reader: {
type: 'json',
root: 'data',
totalProperty: 'totalCount'
}
}
});
Code:
//cases_form_class Ext.define('cases.Form', {
extend: 'Ext.form.Panel',
alias: 'widget.cases_form_class',
requires: ['Ext.form.field.Text'],
initComponent: function(){
this.addEvents('create');
Ext.apply(this, {
activeRecord: null,
//width: 600,
border: false,
bodyBorder: false,
bodyStyle:'padding:0 10px 0 0',
fieldDefaults: {
labelAlign: 'left',
labelWidth: 100,
msgTarget: 'side'
},
items: [{
xtype:'tabpanel',
plain:true,
layout:'fit',
activeTab: 0,
defaults:{bodyStyle:'padding:10px'},
items:[{
title:'Case Informations',
defaults: {width: 350},
defaultType: 'textfield',
items: [{
xtype: 'combo',
triggerAction: 'all',
editable: false,
fieldLabel: 'Title',
name: 'case_mt',
displayField: 'name',
valueField: 'id',
queryMode: 'remote',
store: case_mtstore
}]
}]
}]
});
this.callParent();
}
});
Code:
//cases_grid_class Ext.define('cases.Grid', {
extend: 'Ext.grid.Panel',
alias: 'widget.cases_grid_class',
requires: [
'Ext.grid.plugin.CellEditing',
'Ext.form.field.Text',
'Ext.toolbar.TextItem'
],
initComponent: function(){
Ext.apply(this, {
iconCls: 'icon-grid',
frame: true,
autoScroll:true,
.... <other code>
columns: [{
text: 'ID',
width: 100,
sortable: true,
dataIndex: 'id'//modify
},{
header: 'Title',
flex: 1,
sortable: true,
dataIndex: 'case_title',
field: {
type: 'textfield'
}
}]
});
this.callParent();
this.getSelectionModel().on('selectionchange', this.onSelectChange, this);
}
});
Code:
var manage_cases_com = Ext.create('Ext.container.Container', { padding: '0 0 0 0',
autoScroll:true,
renderTo: document.body,
items: [{//cases_grid_panel
itemId: 'cases_grid_panel',
xtype: 'cases_grid_class',
title: 'Cases Info Lists',
autoScroll : true,
height: 400,
layout:'fit',
store: cases_grid_store,
listeners: {
selectionchange: function(selModel, selected) {
manage_cases_com.child('#cases_form_panel').setActiveRecord(selected[0] || null); <--
Here fired the setvalue function();
}
}
},{//cases_form_panel
itemId: 'cases_form_panel',
padding: '0 10 0 0',
xtype: 'cases_form_class',
layout:'fit',
listeners: {
create: function(form, data){
cases_grid_store.insert(0, data);
}
}
}]
});