Search code examples
listextjssencha-touchdisclosure

How to Apply Disclosure only to Certain Group(s)?


I currently have grouping like this:

enter image description here

Code:

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

var store = new Ext.data.JsonStore({
    model  : 'Contact',
    getGroupString : function(record) {
        //return record.get('lastName')[0];
        return record.get('group');
    },
    data: [
        {firstName: 'Tung', lastName: 'Hauw', group: 'Parents'},
        {firstName: 'Regina', lastName: 'Clarissa', group: 'Parents'},
        {firstName: 'Melvin', lastName: 'Gilbert', group: 'Children'},
        {firstName: 'Jeaffrey', lastName: 'Gilbert', group: 'Children'},
        {firstName: 'Melissa', lastName: 'Merryl Gilbert', group: 'Children'},
        {firstName: 'Jesica', lastName: 'Merryl Gilbert', group: 'Children'}
    ]
});

var list1 = new Ext.List({
    flex: 1,
    cls: 'list_simple',
    sorters: ['firstName', 'group'],
    itemTpl: '{firstName} {lastName}',
    grouped: true,
    groupTpl : [
        '<tpl for=".">',
            '<div class="x-list-group x-group-{id}">',
                '<h3 class="x-list-header"><div class="header">{group}</div></h3>',
                '<div class="x-list-group-items">',
                    '{items}',
                '</div>',
            '</div>',
        '</tpl>'
    ],
    onItemDisclosure: function(record, btn, index) {
        Ext.Msg.alert('Tap', 'Disclose more info for ' + record.get('firstName') + ' ' + record.get('lastName'), Ext.emptyFn);
    },
    store: store
});

I need to have specific disclosure for specific group. With my code above, I get all groups have the same disclosure. I'm trying to achieve this design:

enter image description here

No disclosure for Parent's items. If we slide on Parent's row, we will see Remove button. Also, it has tap event.

I don't have idea where I should move/change the disclosure event. Could someone help me?


Solution

  • The best way to change the disclosure appearance is by using the group's CSS class. If you add a rule to target the disclosure. I'm not 100% certain on the style rule you use (webkit-mask-box-image I think), but if you add a rule like this to your CSS it should work...

    x-list-group x-group-{id} .x-list-disclosure {
       -webkit-mask: none;
       -webkit-mask-box-image: none;
    }
    

    Obviously, change the {id} part to reflect the ID of your parent group, and that way none of your parent items will have the disclosure icon.

    Reference