2012-10-05 2 views
0

기본적으로 나는 다른 사람이 디자인 한 웹 사이트를 가지고 있으며 실제로 ExtJS를 이해하지 못합니다. 아무도 나를 도울 수 있는지 궁금해서.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;  
}; 

답변

0

당신은 서버에서 데이터를 검색하는 storedatachanged 이벤트를 수신하고 싶습니다. 그런 다음 datachanged에서 열 머리글을 가져 와서 업데이트하십시오.

다음 코드 단편은 그리드에 적용된 store에 수신기를 추가하여이를 수행하는 방법의 예입니다.

업데이트 코드 예제

변경 편의를 위해 이름 열

{ 
    header: 'Name' 
    ,id: 'mnwg-grid-charities-name' 
    ,dataIndex: 'Name' 
    ,sortable: true 
    ,width: 400 
    ,editor: { xtype: 'textfield' } 
} 

이 라인MNWG.grid.Charities.superclass.constructor.call(this,config);

MNWG.grid.Charities.getStore().addListener('datachanged', function(store) { 
    Ext.ComponentManager.get('mnwg-grid-charities-name').setText('Name ' + store.count()); 
}); 
+0

리스너가 정상 이하가 아래에 다음 코드를 추가합니다 'fields : ['? 만약 그것이 작동하지 않는다면 :( –

+0

번호. 그리드를 공급하는 상점에 적용해야합니다.이 설정은 코드에 포함되어 있지 않으므로 정확한 예제를 제공 할 수 없습니다. –

+0

내 파일에 포함 된 모든 것을 포함하도록 내 코드 샘플을 업데이트했습니다. 저장소가있는 곳을 볼 수 있습니까? 검색 한 결과가 표시됩니다. 단어 "상점"전체 사이트 코드 및 아무것도 찾을 수 없습니다. –

관련 문제