0

基本的に私は他の誰かによってデザインされたウェブサイトを持っています、そして私は本当にExtJSを理解していません。誰か助けてくれないかと思っていました。

基本的に私がする必要があるのは、スクリプトによってプルされた「名前」の合計量を配置し、それを「名前」列ヘッダーの横に配置することです。

コードで.getCount()やその他のさまざまな関数を試しましたが、何も機能しないようです。

誰かが私をplzするのを手伝ってもらえますか?

ありがとうございました!

    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;    
};
4

1 に答える 1

0

サーバーからデータを取得するストアでdatachangedイベントをリッスンする必要があります。次に、datachangedで列ヘッダーを取得し、更新します。

次のコードスニペットは、グリッドに適用されたストアにリスナーを追加することでこれを実現する方法の例です。

更新されたコード例

わかりやすくするために[名前]列を変更します

{
    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());
});
于 2012-10-05T10:55:29.713 に答える