Skip to content Skip to sidebar Skip to footer

Customizing Html For The List View Cell

A cell of my Sencha touch list view appears as follows; But, i want the text to display on the side as shown in the following image. How can i do this. My code looks like this : &

Solution 1:

Try my code and you can use this to build on

var list = { xtype: 'list',
        id: 'list_product',
        emptyText: '<div class="list-empty-text">No hay coincidencias</div>',
        data: [
            {IMAGE_URL: "t1", MAIN: "Test1", SUBMAIN : "test sub1", COST : "30" }, 
            {IMAGE_URL: "t2", MAIN: "Test2", SUBMAIN : "test sub2", COST : "40" }],
        itemTpl: new Ext.XTemplate(
        '<tpl for=".">',
        '<div class = "details">',
            '<div class="maindetails">',
               '<img src="{IMAGE_URL}" align="top" class="textmiddle"/>',   
                '<div class="maincontent">',
                    '<p>{MAIN}</p>',
                    '<p>{SUBMAIN} <span class="x-button btn">${COST}</span></p>',
                '</div>',
            '</div>',
        '</div>',           
        '</tpl>'
        ),
        listeners: [
            {
            element: 'element',
            delegate: 'span.x-button.btn',
            event: 'tap',
            fn: function() {
                alert('handle button');
            }
        } 
        ]
    };

css

please note that following css works.. but you can write better than this to get same output and i am still learning css

.detailsimg {
    width: 50px;
    height: 50px;
}

.maindetails.maincontent{
    margin-top : -50px;
    margin-left : 70px;
}

.btn {
    width : 45px;
    float : right;
}

Solution 2:

in your css file, set image as inline. And, do the same for the text afterwards.

img {
  display:inline;
}

I think this should solve the problem of displaying text next to the image. Then you could give the image margins so as to improve the looks.

You can use

<inputtype="button" name="button" value="Press this for alert"> 

for creating a button.

Post a Comment for "Customizing Html For The List View Cell"