Results 1 to 4 of 4

Thread: Calling set from within a convert function

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User alumb's Avatar
    Join Date
    Apr 2009
    Vancouver, BC, Canada

    Default Calling set from within a convert function


    Ext version tested:

    • Ext 4.1.0 rev Build date: 2012-04-20 14:10:47 (19f55ab932145a3443b228045fa80950dfeaf9cc)
    Browser versions tested against:
    • Chrome
    • Calling from within another function call (ie via the convert function) causes infinite recursion.
    Steps to reproduce the problem:
    • Add a convert function to field1 that calls set('field2', value).
    • call set('field1',value).
    The result that was expected:
    • both fields are set to the same value
    The result that occurs instead:
    • infinite recursion

    I have two fields in a model such that when one ('title') is updated I need another ('text') to be updated. My solution in Ext.js 4.0 was to set the titles convert function to :
    convert: function(value, me) { me.set('text',value); return value };
    this ment that when set('title',value) was called, the text value was also set. However in Ext.js 4.1, this breaks.

        // This object is used whenever the set() method is called and given a string as the
        // first argument. This approach saves memory (and GC costs) since we could be called
        // a lot.
        _singleProp: {},
    This means that if sets are called recursivly, the same object is used, and it throws Ext.js into an infinite recusion. The second time set is called the _singleProp object has both 'title' and 'text' properties and it infinitly tries to set 'title', which causes another set to be called, causing it to try to set 'title'.... and so on.

    I understand that using a common object is a good idea, but there needs to be a solution for if set is called from within another set.

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL


    The correct way for a field to be updated even if you are using a convert method is to set the field as an empty string. So in your case when you are updating the record you should set the text field to an empty string and the convert method for that field will fire.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:

    Posts are my own, not any current, past or future employer's.

  3. #3

    Default Come again?

    Mitchell - can explain that answer please.

    If I need to set field B to 'world' when field A is set to 'hello' like this:

    convert : function(value, record) {
    if(value === 'hello') {
    record.set('B', 'world');
    I get a recursive loop of death. Setting B to an empty string has the same outcome.

  4. #4


    Addition for anyone who cares:
    Code: = 'world'
    Works for my purposes, without triggering A's convert function

Tags for this Thread

Posting Permissions

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