Results 1 to 6 of 6

Thread: Calculated fields don't work for ExtJS 5 model built for production with cmd

    Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1
    Sencha Premium Member
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    261

    Default Calculated fields don't work for ExtJS 5 model built for production with cmd

    I am using Ext JS 5.0.1255 with SA 3.1.0.1943 and cmd 5.1.0.26

    I am finding that if I build my application for production the calculated model fields are not functioning in IE (have tested versions 8 and 11); they work fine in Firefox.

    I don't have an isolated test case and I am unlikely to producing one (instead I will be converting across to using functions).

    In case it is relevant, the model I am hitting the problem with has a proxy defined that uses directFN to specify a json data source and is populated by invoking load() on the model class.

    I thought I would raise it anyway so others that hit a similar issue can see they are not alone.

  2. #2
    Sencha Premium User lumberjack's Avatar
    Join Date
    Nov 2014
    Location
    Kansas
    Posts
    781

    Default

    I see.?Once you have a test case post it back here and I'll get the issue reported up to engineering.?

    Thanks!
    Brian

  3. #3
    Sencha User
    Join Date
    Jul 2014
    Posts
    2

    Default

    I can also confirm this issue. In my case I had a calculated field dependent on a few other fields.

    Simplified code example:

    Code:
    Ext.define('MyComponent', {
        extend: 'Ext.data.Model',
    
        fields: [
            { name: 'param1', type: 'string' },
            { name: 'param2', type: 'string' },
            { name: 'param3', type: 'number'},
            { name: 'param4', calculate: function(data) {
                return data.param1 || data.param2 + '(' + data.param3 + ')';
            }}
       ],
        /* .. */
    }
    My code then set the following data:

    Code:
    myComponent.set('param2', 'two'); 
    myComponent.set('param3', 3);
    Then, on IE when built for production, running myComponent.get('param4') will return (3) instead of the correct value two (3).

    Note:
    • Chrome and Firefox are OK and returns two (3)
    • IE, when not built for production is also OK and then returns two (3)

  4. #4
    Sencha Premium Member Springvar's Avatar
    Join Date
    Oct 2010
    Location
    Trondheim, Norway
    Posts
    5

    Default

    Seen in Ext JS 5.1.0.107

    The bug is in the argumentNamesRe regular expression in Ext.data.field.Field (Line 763)
    IE will toString() functions with no whitespace before the arguments paranthesis, but the argumentNamesRe expression demands one or more whitespaces.

    Since the expression fails, dataProp is set to the fallback value 'data'. This works for unoptimized code, but will subtly fail as soon as the variable name is shortened.


    argumentNamesRe: /^function\s+\(\s*([^,\)\s]+)/

  5. #5
    Sencha Premium User Fredric Berling's Avatar
    Join Date
    Sep 2007
    Location
    Sweden
    Posts
    210

    Default

    I can also confirm this problem.

  6. #6
    Sencha User
    Join Date
    Aug 2012
    Posts
    21

    Default

    Quote Originally Posted by Springvar View Post
    Seen in Ext JS 5.1.0.107

    The bug is in the argumentNamesRe regular expression in Ext.data.field.Field (Line 763)
    IE will toString() functions with no whitespace before the arguments paranthesis, but the argumentNamesRe expression demands one or more whitespaces.

    Since the expression fails, dataProp is set to the fallback value 'data'. This works for unoptimized code, but will subtly fail as soon as the variable name is shortened.


    argumentNamesRe: /^function\s+\(\s*([^,\)\s]+)/
    Thank you for this, had searched for quite a while to find the exact cause of the problem - this solved it. I used the following override:

    Code:
    Ext.define('MyApp.overrides.Field', {
        override : 'Ext.data.field.Field',
    
    
        argumentNamesRe: /^function\s*\(\s*([^,\)\s]+)/
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •