首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sencha-touch 2:如何在列表中显示项目

Sencha-touch 2:如何在列表中显示项目
EN

Stack Overflow用户
提问于 2012-09-03 19:59:42
回答 1查看 2.5K关注 0票数 0

我正在将数据从mysql服务器动态加载到一个列表中,该列表的itemTpl定义如下:

代码语言:javascript
复制
itemTpl: "<div class=\"list-item-title\">{item_name}{item_qty}</div><div class=\"list-    item-narrative\">{item_detail}</div>

我已经定义了我的app.css,如下所示。我希望我的"item_name“在列表的最左边,而item_qty在同一行中的最右边。我可以使用许多空格(*),但我想要两个项目之间的一些相对间距。

当我对{item_name}和{item_qty}使用两个不同的div元素时,它们出现在两个不同的行中,而不是在列表中的同一行中。

代码语言:javascript
复制
itemTpl: "<div class=\"list-item-title\">{item_name}</div><div class=\"list-item-qty\">{item_qty}</div><div class=\"list-item-narrative\">{item_detail}</div>

app.css

代码语言:javascript
复制
/* Increase height of list item so title and narrative lines fit */
.x-list .x-list-item .x-list-item-label
{
 min-height: 3.5em!important;
}
/* Move up the disclosure button to account for the list item height increase */
.x-list .x-list-disclosure {
position: absolute;
bottom: 0.85em;
right: 0.44em;
}
.list-item-title
{
    float:left;
    width:100%;
    font-size:90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right:25px;
    line-height:150%;
margin-right:520px;
}
.list-item-narrative
{
    float:left;
    width:95%;

    font-size:90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right:25px;
}
.x-item-selected .list-item-title
{
    color:#ffffff;
}
.x-item-selected .list-item-narrative
{
    color:#ffffff;
}
.notes-list-empty-text
{
    padding:10px;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-04 20:18:11

您的itemTpl如下所示:

代码语言:javascript
复制
itemTpl: "<div class=\"list-item-title\">{item_name}</div><div class=\"list-item-qty\">{item_qty}</div><div class=\"list-item-narrative\">{item_detail}</div>

但是你的app.css是错的。缺少一个类:list-item-qty

试试这个:

代码语言:javascript
复制
/* Increase height of list item so title and narrative lines fit */
.x-list .x-list-item .x-list-item-label
{
 min-height: 3.5em!important;
}
/* Move up the disclosure button to account for the list item height increase */
.x-list .x-list-disclosure {
position: absolute;
bottom: 0.85em;
right: 0.44em;
}
.list-item-title
{
    float:left;
    /*width:100%; //this can't be 100% width*/
    width: 75%; //could be more if you need
    font-size:90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right:25px;
    line-height:150%;
    /*margin-right:520px;*/
}
.list-item-qty
{
    float:right;
    font-size:90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right:25px; //You will need that when onItemDisclosure is set to true
    line-height:150%;
    clear: right;
}
.list-item-narrative
{
    float:left;
    width:95%;

    font-size:90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right:25px;
}
.x-item-selected .list-item-title
{
    color:#ffffff;
}
.x-item-selected .list-item-narrative
{
    color:#ffffff;
}
.notes-list-empty-text
{
    padding:10px;
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12247474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档