Column name is not overriding for column extended using Gnt.column.Duration

Discuss issues related to v5.x
User avatar
bksundeepv
Premium Member
Premium Member
Posts: 12
Joined: Thu Mar 07, 2019 10:58 am

Column name is not overriding for column extended using Gnt.column.Duration

Post by bksundeepv » Fri Mar 15, 2019 8:31 am

Hi,

We have defined a new columns by extended 'Gnt.column.Duration'. Provided text property. However, it is not picking up the text property in the from new class. It is picking up text from 'Gnt.column.Duration'. Text displayed for column in Add New column is 'Duration' instead of 'Remaining Effort'.

Provided below new class definition. Any help? Also, is there a way to dynamically change the text property at runtime?

Code: Select all

Ext.define('oracle.apps.projects.projectManagement.brytumUI.column.RemainingEffort', {
    extend: 'Gnt.column.Duration',

    alias: [
        'widget.remainingeffortcolumn',
        'widget.ganttcolumn.remainingeffort'
    ],

    requires: ['oracle.apps.projects.projectManagement.brytumUI.field.RemainingEffort'],

    /**
     * @cfg {Object} l10n
     * A object, purposed for the class localization. Contains the following keys/values:
     *
     * - text : 'Remaining Effort'
     */

Thanks
Sundeep...

User avatar
pmiklashevich
Core Developer
Core Developer
Posts: 1010
Joined: Fri Apr 01, 2016 11:08 am

Re: Column name is not overriding for column extended using Gnt.column.Duration

Post by pmiklashevich » Fri Mar 15, 2019 2:08 pm

Hello Sundeep,

The value is taken from the localization file (Gnt.locale.En)

Code: Select all

        'Gnt.column.Duration' : {
            text : 'Duration'
        },
Please see localization guide for details: https://www.bryntum.com/docs/gantt-for- ... calization

"text" for this column is set in Gnt.column.mixin.TaskFieldColumn

Code: Select all

    initTaskFieldColumn : function (editorCfg) {
        this.text       = this.config.text || this.L('text');
Cheers,
Pavel
Pavel Miklashevich - Core Developer

User avatar
bksundeepv
Premium Member
Premium Member
Posts: 12
Joined: Thu Mar 07, 2019 10:58 am

Re: Column name is not overriding for column extended using Gnt.column.Duration

Post by bksundeepv » Fri Mar 15, 2019 2:45 pm

Hi Pavel,

Modified code as per your suggestion but it is still not working. Can you help me? I have put the breakpoint in initTaskFieldColumn and executed is paused at break point but it is still not working.

Code: Select all

Ext.define('oracle.apps.projects.projectManagement.brytumUI.column.RemainingEffort', {
    extend: 'Gnt.column.Duration',
    mixins : ['Gnt.column.mixin.TaskFieldColumn'],

    alias: [
        'widget.remainingeffortcolumn',
        'widget.ganttcolumn.remainingeffort'
    ],
    requires: ['oracle.apps.projects.projectManagement.brytumUI.field.RemainingEffort'],

    initTaskFieldColumn : function (editorCfg) {
        this.text       = 'Remaining Effort';
        this.callParent(arguments);
    }
}    

Thanks
Sundeep...

User avatar
pmiklashevich
Core Developer
Core Developer
Posts: 1010
Joined: Fri Apr 01, 2016 11:08 am

Re: Column name is not overriding for column extended using Gnt.column.Duration

Post by pmiklashevich » Fri Mar 15, 2019 3:17 pm

I'm sorry, perhaps I wasn't clear enough. I showed you where it happens only to give you some understanding of how it works. Please leave it as is and extend localization instead to have your own translation.

Code: Select all

this.config.text || this.L('text');
This code means that if someone provides its own name to the config it will have priority over the localization. For example:

Code: Select all

new oracle.apps.projects.projectManagement.brytumUI.column.RemainingEffort({ text : 'MyText' });
Pavel Miklashevich - Core Developer

User avatar
bksundeepv
Premium Member
Premium Member
Posts: 12
Joined: Thu Mar 07, 2019 10:58 am

Re: Column name is not overriding for column extended using Gnt.column.Duration

Post by bksundeepv » Mon Mar 18, 2019 7:31 am

Hi Pavel,

We want to add this new column(oracle.apps.projects.projectManagement.brytumUI.column.RemainingEffort) to "Add New Column" list. It is observed that "Add new column" is calling following method to create the list. It is using the cls.prototype.localize('text')/cls.prototype.text to get the column name. For our newly added column it is giving "Duration" instead of "Remaining Effort". Hence we are not able to override it.

Also, if we don't want the default "Duration" column which is provided by Bryntum in Add new column list, is there away to do that?


Code: Select all

buildDefaultColumnList : function () {
            var list = [];

            Ext.Array.each(Ext.ClassManager.getNamesByExpression('widget.ganttcolumn.*'), function (name) {
                var cls = Ext.ClassManager.get(name);

                if (cls && !cls.prototype.ignoreInAddMenu) {
                    list.push({
                        clsName : name,
                        text    : cls.prototype.localize ? cls.prototype.localize('text') : cls.prototype.text
                    });
                }
            });
 
Thanks
Sundeep...

User avatar
pmiklashevich
Core Developer
Core Developer
Posts: 1010
Joined: Fri Apr 01, 2016 11:08 am

Re: Column name is not overriding for column extended using Gnt.column.Duration

Post by pmiklashevich » Mon Mar 18, 2019 7:19 pm

Hello Sundeep,

Let me show you how to do it on Advanced demo. Please add this code to the top of examples/advanced/app/view/Gantt.js:

Code: Select all

Ext.define(null, {
    override        : 'Gnt.column.Duration',
    ignoreInAddMenu : true // to do not show it in Add new column
});

Ext.define('RemainingEffortColumn', {
    extend          : 'Gnt.column.Duration',
    alias           : [
        'widget.remainingeffortcolumn',
        'widget.ganttcolumn.remainingeffortcolumn' // to show it in Add new column
    ],
    ignoreInAddMenu : false // to show it in Add new column because parent now has `true` value
});
And add this code to examples/advanced/app/locale/En.js and all the translations of 'Remaining Effort' to the examples/advanced/app/locale/* files:

Code: Select all

Ext.define('Gnt.examples.advanced.locale.En', {
    extend    : 'Sch.locale.Locale',
    requires  : 'Gnt.locale.En',
    singleton : true,

    l10n : {
        'RemainingEffortColumn' : {
            text : 'Remaining Effort'
        },
        ...
Best wishes,
Pavel
Pavel Miklashevich - Core Developer

User avatar
bksundeepv
Premium Member
Premium Member
Posts: 12
Joined: Thu Mar 07, 2019 10:58 am

Re: Column name is not overriding for column extended using Gnt.column.Duration

Post by bksundeepv » Tue Mar 19, 2019 2:25 pm

Hi Pavel,

This is working fine if we extend any Bryntum Classes. However, if we extend Ext JS classes. This is not working. Provided Example below. Can you help?

Code: Select all

Ext.define('ExpenseResources', {
    extend          : 'Ext.grid.column.Column',
    alias           : [
        'widget.expenseresources',
        'widget.ganttcolumn.expenseresourcescolumn'
    ],
    ignoreInAddMenu : false 
});
I have defined the localization using following code but this is not working. Can you help?

Code: Select all

Ext.define('Gnt.examples.advanced.locale.En', {
    extend    : 'Sch.locale.Locale',
    requires  : 'Gnt.locale.En',
    singleton : true,

    l10n : {
        'ExpenseResources' : {
            text : 'Expense Resources'
        },
        
Thanks
Sundeep
Thanks
Sundeep...

User avatar
pmiklashevich
Core Developer
Core Developer
Posts: 1010
Joined: Fri Apr 01, 2016 11:08 am

Re: Column name is not overriding for column extended using Gnt.column.Duration

Post by pmiklashevich » Tue Mar 19, 2019 4:37 pm

Hello Sundeep,

Please check out Applying localization to a component chapter of the localization guide.

You need to mix Localizable mixin to your component:

Code: Select all

Ext.define('ExpenseResources', {
    extend : 'Ext.grid.column.Column',
    mixins : ['Gnt.mixin.Localizable'], // this is required to be able to get translation for the class
    alias  : [
        'widget.expenseresources',
        'widget.ganttcolumn.expenseresourcescolumn'
    ],

    initComponent : function () {
        this.text = this.config.text || this.L('text'); // this is required to get text value from the translation

        this.callParent(arguments);
    }
});
As an alternative you can also mix TaskFieldColumn mixin to your component:

Code: Select all

Ext.define('ExpenseResources', {
    extend : 'Ext.grid.column.Column',
    mixins : [
        'Gnt.mixin.Localizable', // this is required to be able to get translation for the class
        'Gnt.column.mixin.TaskFieldColumn' // this.text = this.config.text || this.L('text'); will be called under the hood of this mixin
    ],
    alias  : [
        'widget.expenseresources',
        'widget.ganttcolumn.expenseresourcescolumn'
    ],

    initComponent : function () {
        this.initTaskFieldColumn(); // init the mixin

        this.callParent(arguments);
    }
});
Cheers,
Pavel
Pavel Miklashevich - Core Developer

User avatar
bksundeepv
Premium Member
Premium Member
Posts: 12
Joined: Thu Mar 07, 2019 10:58 am

Re: Column name is not overriding for column extended using Gnt.column.Duration

Post by bksundeepv » Wed Mar 20, 2019 11:54 am

Thanks Pavel. Issue is resolved now. Able to pick column names for both grid levels as well as add new column.
Thanks
Sundeep...

User avatar
bksundeepv
Premium Member
Premium Member
Posts: 12
Joined: Thu Mar 07, 2019 10:58 am

Re: Column name is not overriding for column extended using Gnt.column.Duration

Post by bksundeepv » Thu Mar 21, 2019 8:14 am

Hi Pavel,

Obversed new issue. We have extended Gnt column and added it to Add new column. When we select this column from Add new column, it is not added to gantt. Provided code below. Can you help us?

Code: Select all

Ext.define('oracle.apps.projects.projectManagement.brytumUI.column.ActualEffort', {
    extend: 'Gnt.column.ActualEffort',
    xtype: 'pjtactualeffortcolumn',
    alias: [
        'widget.pjtactualeffortcolumn',
        'widget.ganttcolumn.pjtactualeffortcolumn'
    ],

    requires: ['Gnt.column.ActualEffort'],
    width: 150,
    hidden: true,
    filter: {
        type: 'number'
    }

});
Thanks
Sundeep...

Post Reply