Load Data in Modx FormPanel
I'm working on a Customer Manager Page that basically displays the details of a person object(first name, last name...) using display fields without any editing, my view widget is as follows:
Players.panel.View = function(config) {
config = config || {};
Ext.apply(config,{
border: false
,baseCls: 'modx-formpanel'
,url: Players.config.connectorUrl
,baseParams: { action: 'mgr/player/get' }
,items: [{
html: '<h2>'+_('players.view.title')+'</h2>'
,border: false
,cls: 'modx-page-header'
},{
xtype: 'modx-tabs'
,bodyStyle: 'padding: 10px'
,defaults: { border: false ,autoHeight: true }
,border: true
,items: [{
title: _('players.view.tab-header')
,defaults: { autoHeight: true }
,items: [{
html: '<p>'+_('players.view.panel-desc')+'</p><br />'
,border: false
} ,{
xtype: 'compositefield',
labelWidth: 120,
items: [{
xtype : 'displayfield',
value: 'First Name:',
width : 120
},
{
xtype : 'displayfield',
value: 'Yehia A.Salam'
}
]
}]
开发者_开发问答 }]
}]
});
Players.panel.View.superclass.constructor.call(this,config);
};
Ext.extend(Players.panel.View,MODx.Panel);
Ext.reg('players-panel-view',Players.panel.View);
However, the 'mgr/player/get' never gets called, i'm sure the connector is working fine since am already using it in another grid widget, am i missing something here, how do i initiate and the ajax call and populate the displayFields.
Appreciate the Help, And WOW, never thought the learning curve would be so steep for Modx Revolution.
-- Regards. Yehia A.Salam
Try adding the 'fields' parameter that contains all data fields you want to retrieve via the connector.
Something like that:
Players.panel.View = function(config) {
config = config || {};
Ext.apply(config,{
border: false
,baseCls: 'modx-formpanel'
,url: Players.config.connectorUrl
,baseParams: { action: 'mgr/player/get' }
,fields: [
'id'
,'first_name'
,'last_name'
,...]
,...
});
...
You might need to create another custom xtype which will call that connector.
Players.panel.View = function(config) {
config = config || {};
Ext.apply(config,{
border: false
,baseCls: 'modx-formpanel'
,items: [{
html: '<h2>'+_('players.view.title')+'</h2>'
,border: false
,cls: 'modx-page-header'
},{
xtype: 'modx-tabs'
,bodyStyle: 'padding: 10px'
,defaults: { border: false ,autoHeight: true }
,border: true
,items: [{
title: _('players.view.tab-header')
,defaults: { autoHeight: true }
,items: [{
html: '<p>'+_('players.view.panel-desc')+'</p><br />'
,border: false
} ,{
// this thing is the one that has the url + baseParams
// and renders the compositefields
xtype: 'another-xtype-to-call-connector'
,preventRender: true
}]
}]
}]
});
Players.panel.View.superclass.constructor.call(this,config);
};
Ext.extend(Players.panel.View,MODx.Panel);
Ext.reg('players-panel-view',Players.panel.View);
In here, MODx.Panel
is only to generate the layout.
精彩评论