ching29
20 Jul 2016, 12:37 AM
Hello,
I have a form with textfields and grids on it. I have populated data in the textfields from servlet by using the code below that is in my controller.
view.down('form').loadRecord(record);
Is there any way to populate data to the grids? I tried passing the data from controller to view and it properly worked by using the code below.
Controller:
var comboTopics = Ext.create('tdo.store.Topics',{
fields: ['topicCode'],
data : [
{"topicCode":"AP-018"},
{"topicCode":"FIN-004"},
{"topicCode":"GEN-013"}
]
});
var view = Ext.create('tdo.view.trngRecords.Edit',{id:Ext.id(),topics:comboTopics})
View:
initComponent: function() {
this.topics = this.topics;
console.log(this.topics);
this.callParent();
}
My problem is how can I make this store appear on my grid? and am I on the right track? Please help.
Code of my grid:
var comboTopics = Ext.create('Ext.data.Store', {
fields: ['topicCode'],
});
var topicGrid = Ext.create('Ext.grid.Panel', {
store: comboTopics,
columns: [{
header: 'Topic',
dataIndex: 'topicCode',
flex: 1,
allowBlank: false,
renderer: function(topicCode) {
console.log(topicCode);
var index = storeTopics.find('topicCode', topicCode);
console.log(storeTopics);
console.log(index);
return (index === -1) ? "" : storeTopics.getAt(index).get('topicDesc');
},
editor: {
xtype: 'combobox',
store: storeTopics,
queryMode: 'local',
displayField: 'topicDesc',
valueField: 'topicCode',
forceSelection:true
}
}]
});
I have a form with textfields and grids on it. I have populated data in the textfields from servlet by using the code below that is in my controller.
view.down('form').loadRecord(record);
Is there any way to populate data to the grids? I tried passing the data from controller to view and it properly worked by using the code below.
Controller:
var comboTopics = Ext.create('tdo.store.Topics',{
fields: ['topicCode'],
data : [
{"topicCode":"AP-018"},
{"topicCode":"FIN-004"},
{"topicCode":"GEN-013"}
]
});
var view = Ext.create('tdo.view.trngRecords.Edit',{id:Ext.id(),topics:comboTopics})
View:
initComponent: function() {
this.topics = this.topics;
console.log(this.topics);
this.callParent();
}
My problem is how can I make this store appear on my grid? and am I on the right track? Please help.
Code of my grid:
var comboTopics = Ext.create('Ext.data.Store', {
fields: ['topicCode'],
});
var topicGrid = Ext.create('Ext.grid.Panel', {
store: comboTopics,
columns: [{
header: 'Topic',
dataIndex: 'topicCode',
flex: 1,
allowBlank: false,
renderer: function(topicCode) {
console.log(topicCode);
var index = storeTopics.find('topicCode', topicCode);
console.log(storeTopics);
console.log(index);
return (index === -1) ? "" : storeTopics.getAt(index).get('topicDesc');
},
editor: {
xtype: 'combobox',
store: storeTopics,
queryMode: 'local',
displayField: 'topicDesc',
valueField: 'topicCode',
forceSelection:true
}
}]
});