Ext.util.Format.comboRenderer = function(combo){
return function(value){
var record = combo.findRecord(combo.valueField, value);
return record ? record.get(combo.displayField) : combo.emptyText;
}
}
Ebents.combo.organizer = function(config){
config = config || {};
Ext.applyIf(config,{
url: Ebents.config.connectorUrl,
baseParams: { action: 'mgr/organizers/getComboBoxList', combo: true },
hiddenName: 'organizer',
name: 'organizer',
displayField: 'name',
valueField: 'id',
fields: ['id','name'],
loadingText: 'Loading...',
emptyText: 'Select...'
});
Ebents.combo.organizer.superclass.constructor.call(this,config);
};
Ext.extend(Ebents.combo.organizer,MODx.combo.ComboBox);
Ext.reg('ebents-combo-organizer',Ebents.combo.organizer);
Ebents.grid.Events = function(config) {
config = config || {};
Ext.applyIf(config,{
url: Ebents.config.connectorUrl
,baseParams: { action: 'mgr/events/getlist'}
,fields: ['id','name','description','organizer','venue','start','end','status']
,trackMouseOver:true
,disableSelection:true
,loadMask: true
,save_action: 'mgr/events/updateFromGrid'
,autosave: true
,paging: true
,remoteSort: false
,anchor: '97%'
,columns: [{
...
},{
header: _('ebents.event_organizer')
,dataIndex: 'organizer'
,sortable: true
,width: 100
,editor: { xtype: 'ebents-combo-organizer'}
,renderer: Ext.util.Format.comboRenderer(Ebents.combo.organizer)
},{
...
}
]
});
Ebents.grid.Events.superclass.constructor.call(this,config)
};
Ext.reg('ebents-grid-events',Ebents.grid.Events);
Uncaught TypeError: combo.findRecord is not a function(anonymous function) @ events.grid.js:3Ext.grid.GridView.Ext.extend.doRender @ ext-all.js:21
This question has been answered by goldsky. See the first response.
If using a ComboBox in an Editor Grid a renderer will be needed to show the displayField when the editor is not active. Set up the renderer manually, or implement a reusable render, for example:
// create reusable renderer Ext.util.Format.comboRenderer = function(combo){ return function(value){ var record = combo.findRecord(combo.valueField, value); return record ? record.get(combo.displayField) : combo.valueNotFoundText; } }
You need to remove that ,renderer:...
It's meant to manipulate/how to render the content of that column/field.
What you need to focus is the editor: {xtype: 'ebents-combo-organizer'}
renderer: function(value) {
console.log('value', value);
return value;
}try this:
renderer: function(value) { console.log('value', value); return value; }
what do you get on your browser console?
Works now. So simple it's scary. I guess renderer: true has some different logic underneath than just returning the value. Thanks. Maybe should add this diddy to the combobox docs for remote as there is only a local example there. Would have saved me some hours. You might want to read my response on https://forums.modx.com/thread/97975/more-cmp-dev-woes---field-names-in-grid#dis-post-529989
I'm pretty sure they are related.
Maybe should add this diddy to the combobox docs for remote as there is only a local example there.No, I'm pretty sure you didn't even need this
renderer: function(value) {
return value;
}