如何访问 Sencha touch List Row 索引、检索值并应用更改?

发布于 2024-12-09 18:21:37 字数 163 浏览 1 评论 0原文

如果我需要为列表中的行提供备用背景颜色,我就会陷入 sencha touch 列表中。还有一个疑问如何在 sencha touch 中自定义列表,因为我需要在列表行中添加文本字段、按钮、图像。我用 html 尝试过,并且能够做到,有什么方法可以直接将 sencha 触摸对象项添加到列表中。请帮助我解决这个问题。

I am stuck in sencha touch list were i need to give alternate background color for the rows in a list. One more doubt how to customize a list in sencha touch , because i need to add text field, button, images in the list row's . I tried it with html and was able to do , is there any way directly adding sencha touch object items to the list.please help me out on this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末蓝 2024-12-16 18:21:37

您可以使用 cls : 'customCls' 一个可选的额外 CSS 类,它将添加到此组件的元素(默认为 '')。这对于使用标准 CSS 规则向组件或其任何子组件添加自定义样式非常有用。也许你想看看这个

编辑:

Ext.regModel('Contact', {
    fields: ['firstName', 'lastName']
});

var store = new Ext.data.JsonStore({
    model  : 'Contact',
    sorters: 'lastName',
    getGroupString : function(record) {
    return record.get('lastName')[0];
    },
    data: [
        {firstName: 'Tommy',   lastName: 'Maintz'},
        {firstName: 'Rob',     lastName: 'Dougan'},
        {firstName: 'Ed',      lastName: 'Spencer'},
        {firstName: 'Jamie',   lastName: 'Avins'},
        {firstName: 'Aaron',   lastName: 'Conran'},
        {firstName: 'Dave',    lastName: 'Kaneda'},
        {firstName: 'Michael', lastName: 'Mullany'},
        {firstName: 'Abraham', lastName: 'Elias'},
        {firstName: 'Jay',     lastName: 'Robinson'}
    ]
});

Ext.onReady(function() {
    var list = new Ext.List({
        fullscreen: true,
        itemTpl : '{firstName} {lastName}',
        grouped : true,
        indexBar: true,
        store: store,
        listeners: {  // here you can add itemtap event and retrieve index number!
            itemtap:function(item,index, e){

                console.log(index);
                //so, now that you have index , you can access specific item
                console.log(this.store.data.items[index]);      
        }   
    },
    });

    list.show();

    console.log(list.getStore().data.items[0]); 
    // here you are accessing list store and then store data and then store item with index 0
}); 

You can use cls : 'customCls' An optional extra CSS class that will be added to this component's Element (defaults to ''). This can be useful for adding customized styles to the component or any of its children using standard CSS rules. And maybe you want to check out this

EDIT:

Ext.regModel('Contact', {
    fields: ['firstName', 'lastName']
});

var store = new Ext.data.JsonStore({
    model  : 'Contact',
    sorters: 'lastName',
    getGroupString : function(record) {
    return record.get('lastName')[0];
    },
    data: [
        {firstName: 'Tommy',   lastName: 'Maintz'},
        {firstName: 'Rob',     lastName: 'Dougan'},
        {firstName: 'Ed',      lastName: 'Spencer'},
        {firstName: 'Jamie',   lastName: 'Avins'},
        {firstName: 'Aaron',   lastName: 'Conran'},
        {firstName: 'Dave',    lastName: 'Kaneda'},
        {firstName: 'Michael', lastName: 'Mullany'},
        {firstName: 'Abraham', lastName: 'Elias'},
        {firstName: 'Jay',     lastName: 'Robinson'}
    ]
});

Ext.onReady(function() {
    var list = new Ext.List({
        fullscreen: true,
        itemTpl : '{firstName} {lastName}',
        grouped : true,
        indexBar: true,
        store: store,
        listeners: {  // here you can add itemtap event and retrieve index number!
            itemtap:function(item,index, e){

                console.log(index);
                //so, now that you have index , you can access specific item
                console.log(this.store.data.items[index]);      
        }   
    },
    });

    list.show();

    console.log(list.getStore().data.items[0]); 
    // here you are accessing list store and then store data and then store item with index 0
}); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文