Results 1 to 10 of 13

Thread: How to insert a picture on the condition itemtpl

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Oct 2013
    Location
    Minsk
    Posts
    43
    Vote Rating
    0
      0  

    Default How to insert a picture on the condition itemtpl

    Hello! Please tell me how to insert a picture on a condition in Itemtpl. I tried to insert a function but does not work ... Thanks in advance.


    Code:
    itemTpl :
                              '<img src="{this.resolveImage(values)}" width=100 height=80 margin-left=50px>'
                             +'<b style="color:#F00">{f1} {mode} {f2} {f3}</b>'
                             +'<p style=color:Gray style=font-size:40px style=font-weight:bold>{f14}</p>'
                             +'<p style=color:Gray style=font-size:40px style=font-weight:bold>{f4} {f13}</p>',
    
                               resolveImage: function () {
                                   if (value.mode == cp && value.f2 == 2 && value.f3 == 0) {
                                       return 'resources/images/goods-dlv.png';
                                   }
                                   return 'resources/images/goods-cap.png';
    
                               },

  2. #2
    Sencha User
    Join Date
    Jul 2013
    Posts
    99
    Vote Rating
    10
      1  

    Default

    Change your code slightly to include square brackets when referencing a function + include the argument in your function:

    Code:
    itemTpl :                          '<img src="{ [this.resolveImage(values)] }" width=100 height=80 margin-left=50px>'
                             +'<b style="color:#F00">{f1} {mode} {f2} {f3}</b>'
                             +'<p style=color:Gray style=font-size:40px style=font-weight:bold>{f14}</p>'
                             +'<p style=color:Gray style=font-size:40px style=font-weight:bold>{f4} {f13}</p>',
    
    
                               resolveImage: function (value) {
                                   if (value.mode == cp && value.f2 == 2 && value.f3 == 0) {
                                       return 'resources/images/goods-dlv.png';
                                   }
                                   return 'resources/images/goods-cap.png';
    
    
                               },

  3. #3
    Sencha User
    Join Date
    Oct 2013
    Location
    Minsk
    Posts
    43
    Vote Rating
    0
      0  

    Default

    still fails to establish code .... the list is not displayed. but rather appears empty .... have empty time ...

    bring clarity to the whole JS....


    Code:
    Ext
            .define(
                    'MM.view.Contacts',
                    {
                        extend : 'Ext.List',
                        xtype : 'contacts',
                        //id    : 'titleform',
                        config : {
                            title : '??? ???????? ',
                            id: 'homeTab',
                            store : 'otprStore',
                            itemTpl :                          '<img src="{ [this.resolveImage(values)] }" width=100 height=80 margin-left=50px>'
                                +'<b style="color:#F00">{f1} {mode} {f2} {f3}</b>'
                                +'<p style=color:Gray style=font-size:40px style=font-weight:bold>{f14}</p>'
                                +'<p style=color:Gray style=font-size:40px style=font-weight:bold>{f4} {f13}</p>',
    
    
                            resolveImage: function (value) {
                                if (value.mode == cp && value.f2 == 2 && value.f3 == 0) {
                                    return 'resources/images/goods-dlv.png';
                                }
                                return 'resources/images/goods-cap.png';
    
    
                            }
                             +'<br><b style="color:#F00">{f1} {mode} {f2} {f3}</b>'
                             +'<p style=color:Gray style=font-size:40px style=font-weight:bold>{f14}</p>'
                             +'<p style=color:Gray style=font-size:40px style=font-weight:bold>{f4}</p>'
                             +'<p style=color:Gray style=font-size:40px style=font-weight:bold>{f13}</p>',
    
    
    
    
    
                            items : [ {
                                xtype : 'toolbar',
                                docked : 'bottom',
                                scrollable : {
                                    direction : 'horizontal',
                                    indicators : false
                                },
                                layout : {
                                    pack : 'center',
                                    align : 'center'
                                },
                                defaults : {
                                    ui : 'plain'
                                },
    
                                items : [
                                        {
                                            xtype : 'button',
                                            text : '',
                                            action : 'logout', // ??????? ??
                                            // ????????
                                            iconCls : 'delete',
                                            ui : 'decline'
                                        },
                                        {
                                            xtype : 'button',
                                            iconCls : 'arrow_left',
                                            id : 'namebutton',
                                            ui : 'back',
                                            handler : function() {
                                                //Ext.getCmp('titleform').setTitle('?????');
                                                var sto = Ext.getStore('otprStore');
                                                sto.clearFilter();
                                                sto.filter('mode', 'cp');
                                                Ext.Msg    .alert(
                                                                'MM-Express',
                                                                '???????????? ?? ????? ????????',
                                                                Ext.emptyFn);
                                               // Ext.getCmp('????????').setTitle('?????');
                                            },
                                            listeners: {
                                            tap: function(button){
                                                var homeTab = button.getParent();
                                                homeTab.tab.setTitle('?????');
                                            }
                                        }
                                        },
                                        {
                                            xtype : 'button',
                                            iconCls : 'arrow_right',
                                            ui : 'forward',
                                            handler : function() {
                                                //Ext.getCmp('titleform').setTitle('????????');
                                                var sto = Ext.getStore('otprStore');
                                                sto.clearFilter();
                                                sto.filter('mode', 'dv');
                                                Ext.Msg
                                                        .alert(
                                                                'MM-Express',
                                                                '???????????? ?? ???????? ????????',
                                                                Ext.emptyFn);
                                            },
                                            listeners: {
                                                tap: function(button){
                                                    var homeTab = button.getParent();
                                                    homeTab.tab.setTitle('????????');
                                                }
                                        }
                                        },
                                        {
                                            xtype : 'button',
                                            iconCls : 'team',
                                            ui : 'action',
                                            handler : function() {
                                                //Ext.getCmp('titleform').setTitle('??? ????????');
                                                Ext.getStore('otprStore')
                                                        .clearFilter();
                                                Ext.Msg.alert('MM-Express',
                                                        '???? ?????? ????????',
                                                        Ext.emptyFn);
                                            },
                                            listeners: {
                                                tap: function(button){
                                                    var homeTab = button.getParent();
                                                    homeTab.tab.setTitle('??? ????????');
                                                }
                                        }
                                        },
                                        {
                                            xtype : 'button',
                                            iconCls : 'refresh',
                                            ui : 'action',
                                            id : 'reload'
    
                                        } ]
                            } ]
    
                        }
    
                    });

  4. #4
    Sencha User
    Join Date
    Oct 2013
    Location
    Minsk
    Posts
    43
    Vote Rating
    0
      0  

    Default

    pls help me...

  5. #5
    Sencha User
    Join Date
    Jul 2013
    Posts
    99
    Vote Rating
    10
      1  

    Default

    1. Can you get it to work with a simple list item, not using a function?
    2. Is it a layout/display? Try setting the minHeight of your list, to make sure it is not a list size issue. Eg. minHeight:'200px' in the config for the list.

  6. #6
    Sencha User
    Join Date
    Oct 2013
    Location
    Minsk
    Posts
    43
    Vote Rating
    0
      0  

    Default

    I get this:
    I get Data from JSON there is the value of "mode" "f2" "f3" fashion on him and is determined by what the picture wakes. It turns out like the picture.

    Why is that instead of a picture put [Object object]

    ??????????.jpg

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
  •