How to change email field attribute label on listview ?

Hi Friends

I want to change the email field attribute label on listview .

ex . if my email-id length is greater then 10 then it will be 3 dots (...) and after @gmail.com

like  abcdefghijklmnerwr@gmail.com but i want to show abcdefghij...@gmail.com

 

Can i achieve by override the list.js ? Ramana Raju Santhana

Parents
  • Hi, Mehul Bhandari!

    Tevfik Tümer gives you correct advice. You need extend your /custom/modules/Contacts/clients/base/fields/email/email.js with format method:

    ({
        extendsFrom: 'BaseEmailField',

        initialize: function(options) {
            this._super('initialize', [options]);
        },

        format: function(value) {
            var value = this._super('format', [value]);

            if (this.action == 'list') {
                //debugger;
                var emailString = '';
                if (_.isArray(value) && value.length > 0) {
                    emailString = value[0].email_address;
                } else {
                    emailString = value;
                }

                if (!_.isUndefined(emailString) && emailString != '') {
                    value[0].email_address = this.formatEmailName(emailString);
                }
            }

            return value;

        },

        formatEmailName: function(email) {
            var emailArray = email.split('@'),
                name = emailArray[0],
                domain = emailArray[1];
            if (name.length > 10) {
                return name.substr(0, 10) + '...@' + domain;
            } else {
                return email;
            }
        }

    });
Reply
  • Hi, Mehul Bhandari!

    Tevfik Tümer gives you correct advice. You need extend your /custom/modules/Contacts/clients/base/fields/email/email.js with format method:

    ({
        extendsFrom: 'BaseEmailField',

        initialize: function(options) {
            this._super('initialize', [options]);
        },

        format: function(value) {
            var value = this._super('format', [value]);

            if (this.action == 'list') {
                //debugger;
                var emailString = '';
                if (_.isArray(value) && value.length > 0) {
                    emailString = value[0].email_address;
                } else {
                    emailString = value;
                }

                if (!_.isUndefined(emailString) && emailString != '') {
                    value[0].email_address = this.formatEmailName(emailString);
                }
            }

            return value;

        },

        formatEmailName: function(email) {
            var emailArray = email.split('@'),
                name = emailArray[0],
                domain = emailArray[1];
            if (name.length > 10) {
                return name.substr(0, 10) + '...@' + domain;
            } else {
                return email;
            }
        }

    });
Children