Results 1 to 3 of 3

Thread: tpl if else question

  1. #1

    Default tpl if else question

    Hi, I'm comparing an element with a
    :
    . How should I do that?

    Code:
    '<tpl if="values.phone != :">'
    So values.phone contains a : or something else but when it's a : I should do something else.

    I also need to check on an empty string.

    Code:
    '<tpl if="values.phone != """>'

  2. #2
    Sencha User AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Answers
    148

    Default

    Check for ":"
    Code:
    "<tpl if='phone == \":\"'>",
     
    "<tpl else>",
       
    "</tpl>"
    Check for empty string
    Code:
    "<tpl if='phone == \"\"'>",
    
    "</tpl>"
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  3. #3
    Sencha User
    Join Date
    Oct 2013
    Posts
    32
    Answers
    2

    Default

    I got stuck with this one, I want to use tpl to set the text of a symptom, in case the symptom is not empty, or otherwise show a default message.

    This is what I have, but doesn't seem to work:

    Code:
    Ext.define('Infections.view.illness.Symptoms', {
        extend: 'Ext.Panel',
        xtype: 'illnessSymptoms',
    
    
        config: {
            title: 'Symptoms',
            iconCls: 'eye',
            tpl: [
                '<tpl if="symptoms == null || symptoms == \"\"">',
                    'No symptoms',
                '<tpl else>',
                    '{symptoms}',
                '</tpl>'
            ]
        }
    });
    Can someone help me out please?

    PS: yes, this panel receives the correct data.

    EDIT:

    Fixed it via:

    Code:
    tpl: Ext.create('Ext.XTemplate',
        '<tpl if="symptoms == null || symptoms == \'\'">',
            'No symptoms found...',
        '<tpl else>',
            '{symptoms}',
        '</tpl>'
    )

Posting Permissions

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