簡體   English   中英

Extjs - 無法隱藏/取消隱藏網格面板中特定行中的操作列圖標

[英]Extjs - Not able to hide/unhide actioncolumn icon in specific rows in Grid panel

我希望根據獲得的行數據隱藏/取消隱藏我在操作列中添加的圖標。 我嘗試使用 getClass function,但該圖標在任何情況下都不會出現。 不使用 getClass function 並且僅使用圖標鍵,我就可以一直顯示圖標(在下面的代碼中注釋掉)。 我在這里想念什么?

this.columns = [{
        xtype: 'actioncolumn',
        itemId:'invalid_icon',
        sortable: false,
        menuDisabled: true,
        cls:'table_invalid_icon',
        width: 70,
        items: [{
            getClass: function(Value, metaData, record){
                if(record.data.name !== 'test' ){
                    return  "hideDisplay";
                }else{
                     return "showIcon";
                }
                    
            }
            //icon: 'image.svg'
        }]
}]

我有相應的 css 如下:

.showIcon{
   background:url('image.svg'); 
}
.hideDisplay{
  background:none; 
}

我還驗證了 if 條件並且條件具有正確的值。 關於我所缺少的任何想法?

為什么你使用背景而不是圖標屬性? 圖標是動態的還是 static?

.hidden {
    display: none
}

和工作樣本:

Ext.create('Ext.data.Store', {
    storeId: 'employeeStore',
    fields: ['firstname', 'lastname', 'seniority', 'dep', 'hired'],
    data: [{
        firstname: "Michael",
        lastname: "Scott"
    }, {
        firstname: "Dwight",
        lastname: "Schrute"
    }, {
        firstname: "Jim",
        lastname: "Halpert"
    }, {
        firstname: "Kevin",
        lastname: "Malone"
    }, {
        firstname: "Angela",
        lastname: "Martin"
    }]
});

Ext.create('Ext.grid.Panel', {
    title: 'Action Column Demo',
    store: Ext.data.StoreManager.lookup('employeeStore'),
    columns: [{
        text: 'First Name',
        dataIndex: 'firstname'
    }, {
        text: 'Last Name',
        dataIndex: 'lastname'
    }, {
        xtype: 'actioncolumn',
        width: 50,
        items: [{
            icon: 'https://docs.sencha.com/extjs/4.2.6/extjs-build/examples/shared/icons/fam/cog_edit.png', // Use a URL in the icon config
            tooltip: 'Edit',
            hidden: true,
            getClass: function (value, metaData, record, rowIndex) {
                if (rowIndex % 2) {
                    return 'hidden'
                }
            },
            handler: function (grid, rowIndex, colIndex) {
                var rec = grid.getStore().getAt(rowIndex);
                alert("Edit " + rec.get('firstname'));
            }
        }]
    }],
    width: 250,
    renderTo: Ext.getBody()
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM