基本上我有别人设计的网站,我真的不懂 ExtJS。我想知道是否有人可以帮助我。
基本上我需要做的是将脚本提取的“名称”总量放在“名称”列标题旁边。
我已经尝试过代码中的 .getCount () 和其他各种函数,但似乎没有任何效果。
任何人都可以帮助我吗?
谢谢!
MNWG.grid.Charities = function(config) {
config = config || {};
Ext.applyIf(config,{
id: 'mnwg-grid-charities'
,url: MNWG.connectorURL
,baseParams: { action: 'charities/getList' }
,fields: ['id','Created','Name','RegNo','Contact','Address','Postcode','Phone','Fax','Website','Email','Info','Notes','Tags',{name: 'FinancialAid',type:'boolean'}]
,paging: true
,remoteSort: true
,anchor: '97%'
,autoExpandColumn: 'name'
,columns: [{
header: 'Name'
,dataIndex: 'Name'
,sortable: true
,width: 400
,editor: { xtype: 'textfield' }
},{
header: 'Contact'
,dataIndex: 'Contact'
,sortable: false
},{
header: 'Post code'
,dataIndex: 'Postcode'
,sortable: false
},{
header: 'Phone'
,dataIndex: 'Phone'
,sortable: false
,renderer: MNWG.renderers.phoneFax
},{
header: 'Website'
,dataIndex: 'Website'
,sortable: false
,renderer: MNWG.renderers.websiteLink
},{
header: 'Email'
,dataIndex: 'Email'
,sortable: false
,renderer: MNWG.renderers.emailLink
}]
,tbar:[{
xtype: 'textfield'
,id: 'mnwg-charities-search-filter'
,emptyText: 'Search...'
,listeners: {
'change': {fn:this.search,scope:this}
,'render': {fn: function(cmp) {
new Ext.KeyMap(cmp.getEl(), {
key: Ext.EventObject.ENTER
,fn: function() {
this.fireEvent('change',this);
this.blur();
return true;
}
,scope: cmp
});
},scope:this}
}
},{
xtype: 'tbfill'
},{
xtype: 'button'
,text: 'Add new Charity'
,handler: {
xtype: 'mnwg-window-createcharity'
,blankValues: true
}
}]
});
MNWG.grid.Charities.superclass.constructor.call(this,config)
};
Ext.extend(MNWG.grid.Charities,MODx.grid.Grid,{
search: function(tf,nv,ov) {
var s = this.getStore();
s.baseParams.query = tf.getValue();
this.getBottomToolbar().changePage(1);
this.refresh();
}
,getMenu: function(a,b,c) {
var items = Array();
// Check for a web url
URL = a.menu.record.Website;
if(URL != '' && URL != '/'){
items.push({
text: 'Visit Website'
,handler: this.visitWebsite
});
};
// Check for an email address
Email = a.menu.record.Email;
if(Email!=''){
items.push({
text: 'Send Email'
,handler: this.sendEmail
});
};
// Add update / delete buttons
items.push({
text: 'Update Details'
,handler: this.updateCharity
},'-',{
text: 'Remove Charity'
,handler: this.removeCharity
});
return items;
}
,visitWebsite: function(a,b){
var url = a.parentMenu.record.Website
// Make sure URL is preceded by http://
var patt= /^http/;
if( ! patt.test(url)){
url = 'http://'+url;
};
window.open(url);
}
,sendEmail: function(a,b){
var Email = a.parentMenu.record.Email
window.open('mailto:'+Email);
}
,removeCharity: function() {
MODx.msg.confirm({
title: 'Delete Charity'
,text: 'Are you sure you want to delete this charity? This cannot be reversed!'
,url: this.config.url
,params: {
action: 'charities/remove'
,id: this.menu.record.id
}
,listeners: {
'success': {fn:this.refresh,scope:this}
,'failure': {fn: function(){ alert('fail'); },scope:this}
}
});
}
,updateCharity: function(btn,e) {
if (!this.updateCharityWindow) {
this.updateCharityWindow = MODx.load({
xtype: 'mnwg-window-updatecharity'
,record: this.menu.record
,listeners: {
'success': {fn:this.refresh,scope:this}
}
});
}
this.updateCharityWindow.setValues(this.menu.record);
this.updateCharityWindow.show(e.target);
}
});
Ext.reg('mnwg-grid-charities',MNWG.grid.Charities);
MNWG.renderers.websiteLink = function(val,a,record){
// If no URL return blank
if(val==''){return'';};
// Make sure URL is preceded by http://
var patt= /^http/;
if( ! patt.test(val)){
val = 'http://'+val;
};
// Create link
return '<a href="'+val+'" target="_blank">Visit Website</a>';
};
MNWG.renderers.emailLink = function(val,a,record){
// If no email return blank
if( val=='' ){return '';};
return '<a href="mailto:'+val+'">Send Email</a>';
};
MNWG.renderers.phoneFax = function(val,a,record){
var html = '';
if(record.data.Phone!=''){
html+= '<img src="http://m.intertrustgroup.com/images/icon_phone.png" style="margin-right:.5em;">'+record.data.Phone+'<br />';
};
if(record.data.Fax!=''){
html+= '<img src="http://www.sliksvn.com/gfx/icon_fax.gif" style="margin-right:.5em;">'+record.data.Fax;
};
return html;
};