Results 1 to 3 of 3

Thread: addCls() on ListItem

  1. #1
    Sencha Premium Member
    Join Date
    Sep 2014
    Posts
    18

    Default Answered: addCls() on ListItem

    I'm attempting to style a ListItem within a List control. I want each instance of the ListItem to have the CSS class 'LPNListItem'. But none of the following approaches apply the 'LPNListItem' CSS class to *any* node in the DOM:

    Code:
    Ext.define('ptl.view.LPNListItemRenderer', {
        extend: 'Ext.dataview.component.ListItem',
        xtype: 'LPNListItemRenderer',
        config: {
            cls: 'LPNListItem',
            ...
    Code:
    Ext.define('ptl.view.LPNListItemRenderer', {
        extend: 'Ext.dataview.component.ListItem',
        xtype: 'LPNListItemRenderer',
        cls: 'LPNListItem',
        ......
    Code:
    updateRecord: function(record) {
        var me = this;
        me.addCls('LPNListItem');
        this.callParent(arguments);
        ...
    

  2. You can add it in the list config:

    Code:
    Ext.define('MyList', {
      extend: 'Ext.List',
    
      config: {
        itemCls: 'LPNListItem'
      }
    });

  3. #2
    Sencha Premium User
    Join Date
    May 2011
    Location
    Gainesville, FL
    Posts
    228
    Answers
    29

    Default

    You can add it in the list config:

    Code:
    Ext.define('MyList', {
      extend: 'Ext.List',
    
      config: {
        itemCls: 'LPNListItem'
      }
    });

  4. #3
    Sencha Premium Member
    Join Date
    Sep 2014
    Posts
    18

    Default need to toggle the class based on data

    I also need to toggle a CSS class based on the data in ListItem, like this:

    Code:
    updateRecord: function(record) {
        if (record.data.sku) {
            me.addCls('isSKU');  // no error, but nothing happens
            Ext.get(me.element).addCls('isSKU');  // no error, but nothing happens
        }
        else {
            me.removeCls('isSKU');
        }
    }
    Neither one of these adds the css class to any dom element on the page.

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
  •