Results 1 to 4 of 4

Thread: how to custom a button in the sencha touch list

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    11
    Vote Rating
    0
      0  

    Post Unanswered: how to custom a button in the sencha touch list

    hi,i am doing a list like tree.
    picture:
    311.jpg

    clicked the blue button and refresh side bar

    like that :

    654.jpg

    i try two soluton.

    1.i cancel the blue button and write a <img src=""....> in the itemtpl,eg:
    Code:
    itemTpl: '<div class="contact2"><strong>{MetricName}</strong><img style="float:right" src="/image/notification_error_meitu_1.jpg"/></div>',
    but i meet a problem that i cannot bind a click function bind to the img.........

    i give up.....

    2.i try still use the blue button,but i don't konw how to control its show or

    hide,if a tree have not child item,i want to hide the button.

    i give up again......

    3.third times, i find a passage that decribe how to custom a list,but when i copy

    these code to my sencha touch project.........the button haven't apper...... i

    feel very strange.

    append code:
    Code:
    Ext.regModel('Example',{
        fields:['id','text']
    });
    
    Ext.regStore('MyStore',{
        model :'Example',
        data:[
            {id : '0', text : 'aaaa'},
            {id : '1', text : 'bbbb'},
            {id : '2', text : 'cccc'},
            {id : '3', text : 'dddd'}
        ]
    });
    
    var myApp =new Ext.Application({    //?????Application????????????
        name: 'myApp',        //?????????
    //useLoadMask: true,
        launch: function () {            //???????
    var list =new Ext.List({
                itemTpl : new Ext.XTemplate(
                    '<div>{text}</div>',
                    '<div style="float:right" id="button_{id}"></div>'),//???id?????????div?????????div?
                store : 'MyStore',
                isAfterrendered : false,    //???????????afterrender??????
                listeners : {
                    afterrender : function() {            //afterrender????list????????????
    this.isAfterrendered =true;    //??this??list
                        console.log('afterrender');        //????????????????
                    },
                    update : function() {    //update???render???????????????
    //???????????list??????????
                        console.log('update');
                        if (this.isAfterrendered) {
                            Ext.each(Ext.StoreMgr.lookup('MyStore').data.items,//?MyStore????????????
    function(arrayItem, index) {
                                    new Ext.Button({
                                        iconMask : true,
                                        ui : 'plain',    //??????
                                        iconCls : 'delete',
                                        renderTo : 'button_'+ arrayItem.data.id
                                    });
                                });
                        }
                    }
            
                }
            });
            
            var panel =new Ext.Panel({
                fullscreen : true, //??????????
                items : list
            });
        }
    });
    passage run picture.........
    58.jpg

    Could you give some advices......thanks

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,324
    Answers
    3884
    Vote Rating
    1297
      0  

    Default

    Are you using Sencha Touch 1 or Sencha Touch 2?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    11
    Vote Rating
    0
      0  

    Post sencha 2

    Quote Originally Posted by mitchellsimoens View Post
    Are you using Sencha Touch 1 or Sencha Touch 2?
    i know i use the sencha 1.1 grammer in sencha 2........

  4. #4
    Sencha User
    Join Date
    Nov 2010
    Posts
    15
    Answers
    3
    Vote Rating
    0
      0  

    Default

    can you ellaborate on this I know the Solution because I have done the custom button with three different states
    normal,pressed and selected

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
  •