Results 1 to 4 of 4

Thread: Using XTemplate when field name contains colon

  1. #1
    Sencha Premium User
    Join Date
    Oct 2015
    Posts
    27

    Default Answered: Using XTemplate when field name contains colon

    Hi guys,

    I ran into a problem someone some years ago already had but it was not answered ..
    https://www.sencha.com/forum/showthr...contains-Colon

    I tried something like this in a list:

    Code:
    itemTpl: ['{BASE:OrderTitle}']
    But I get the following error:

    Code:
    [W] XTemplate evaluation exception: fm.OrderTitle is not a function


    The problem is, I can not change these field names, because I need the original entities for more queries to the server.


    Thanks in advance,
    Phil

  2. Yes, just like before the issue is the same so the fix is the same.



    XTemplate will create variables for the data that is passed in. If it's not a valid variable then you need to use the values object which is the data you pass in.

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    The issue here is that the colon means something to XTemplate, it expects OrderTitle to be a function on Ext.util.Format and there is no changing that.

    You can use the programatic means instead:

    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

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

  4. #3
    Sencha Premium User
    Join Date
    Oct 2015
    Posts
    27

    Default

    Okay, thank you, this works great, when I display these values.
    But now I ran into the next problem with the colons, when I try to use some if-statements:

    Code:
    <tpl if="!BASE:Active"> ... 
    Then I get the "SyntaxError: Unexpected token :"

    Can you help with that, too?


    The following fiddle works without colon, but when you add the "BASE:" to the "Active" field and in the if-clause, it crashes ..



    Thanks in advance,
    Phil

  5. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Yes, just like before the issue is the same so the fix is the same.



    XTemplate will create variables for the data that is passed in. If it's not a valid variable then you need to use the values object which is the data you pass in.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

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

Similar Threads

  1. Using XTemplate when Field Name contains Colon
    By ericc in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 29 Sep 2016, 7:04 AM
  2. How to get value of an element with a tag which contain colon?
    By zengy8000 in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 28 Jun 2012, 7:19 AM
  3. Encoding colon?
    By new2extjs in forum Ext: Q&A
    Replies: 3
    Last Post: 24 Nov 2011, 6:46 AM
  4. Checkbox without the colon (:)?
    By Rodkun in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 6 Oct 2008, 4:36 PM

Posting Permissions

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