Results 1 to 3 of 3

Thread: List.groupTpl cannot accept an XTemplate

Hybrid View

Previous Post Previous Post   Next Post Next Post
    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    24
      0  

    Default List.groupTpl cannot accept an XTemplate

    This could be considered a feature request, as List.groupTpl doesn't show up in the documents so it's hard to say what it's "supposed" to do. However, I've seen it given out by Sencha staff as part of answers, and it isn't marked private in the source code, so I think perhaps you mean for us to use it.

    In any case, the way List.initComponent works, groupTpl can't receive an XTemplate instance, so this means it can't have user functions. This is due to this piece of code in List.initComponent:
    Code:
    if (Ext.isString(this.groupTpl) || Ext.isArray(this.groupTpl)) {
        this.tpl = new Ext.XTemplate(this.groupTpl);
    }
    This strips it of any user functions. Instead, the following could be used:
    Code:
    if (Ext.isString(this.groupTpl) || Ext.isArray(this.groupTpl)) {
        this.tpl = new Ext.XTemplate(this.groupTpl);
    }
    else if (this.groupTpl && this.groupTpl.html)
      this.tpl = new Ext.XTemplate(this.groupTpl.html, this.groupTpl.initialConfig);
    In the meantime, here's the override I'm using as a workaround:
    Code:
    Ext.jep.List = Ext.extend(Ext.List, {
      initComponent : function() {
        Ext.jep.List.superclass.initComponent.apply(this);
        
        if (this.grouped && this.groupTpl && this.groupTpl.html) {
          this.tpl = new Ext.XTemplate(this.groupTpl.html, this.groupTpl.initialConfig);
        }
      }
    });

  2. #2

  3. #3
    Sencha User
    Join Date
    Mar 2008
    Posts
    71
    Vote Rating
    0
      0  

    Default

    I solved this issue by using Ext.createSequence to hook into the Ext.List.prototype.initComponent which is right after this.tpl gets created. I think loop through this.tplFunctions (defined by you) and append them to the this.tpl object using this.tpl[key] = value.

    I have also found through my digging that you can accomplish something similar with NestedLists if you create a sequence or override on the getSubList method which allows you to then modify the this.tpl object and happens early enough that no data has been inserted into the store or rendered yet.

    Hope that helps,

    Jordan

    Quote Originally Posted by jep View Post
    This could be considered a feature request, as List.groupTpl doesn't show up in the documents so it's hard to say what it's "supposed" to do. However, I've seen it given out by Sencha staff as part of answers, and it isn't marked private in the source code, so I think perhaps you mean for us to use it.

    In any case, the way List.initComponent works, groupTpl can't receive an XTemplate instance, so this means it can't have user functions. This is due to this piece of code in List.initComponent:
    Code:
    if (Ext.isString(this.groupTpl) || Ext.isArray(this.groupTpl)) {
        this.tpl = new Ext.XTemplate(this.groupTpl);
    }
    This strips it of any user functions. Instead, the following could be used:
    Code:
    if (Ext.isString(this.groupTpl) || Ext.isArray(this.groupTpl)) {
        this.tpl = new Ext.XTemplate(this.groupTpl);
    }
    else if (this.groupTpl && this.groupTpl.html)
      this.tpl = new Ext.XTemplate(this.groupTpl.html, this.groupTpl.initialConfig);
    In the meantime, here's the override I'm using as a workaround:
    Code:
    Ext.jep.List = Ext.extend(Ext.List, {
      initComponent : function() {
        Ext.jep.List.superclass.initComponent.apply(this);
        
        if (this.grouped && this.groupTpl && this.groupTpl.html) {
          this.tpl = new Ext.XTemplate(this.groupTpl.html, this.groupTpl.initialConfig);
        }
      }
    });

Posting Permissions

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