EXTJS4 查询数据,结果出来,根据某一列数据的值,如果为Y,操作那里显示取消推荐,如果为N就显示推荐

2025-04-17 15:24:23
推荐回答(1个)
回答1:

实例的代码已经可以实现这种需求了

{
                    xtype: 'actioncolumn',
                    width: 50,
                    sortable: false,
                    menuDisabled: true,
                    items: [
                        {
                            handler: function(view, rowIndex, colIndex, item, e) {
                                this.fireEvent('itemclick', this, 'sell', view, rowIndex, colIndex, item, e);
                            },
                            icon: 'images/fam/delete.gif',
                            tooltip: 'Sell stock'
                        },
                        {
                            getClass: function(v, metadata, r, rowIndex, colIndex, store) {
                                if (r.get('change') < 0) {
                                    this.items[1].tooltip = 'Hold stock';
                                    return 'alert-col';
                                } else {
                                    this.items[1].tooltip = 'Buy stock';
                                    return 'buy-col';
                                }
                            },
                            handler: function(view, rowIndex, colIndex, item, e) {
                                var rec = view.getRecords(view.getNodes())[rowIndex];
                                var action = rec.get('change') < 0 ? 'hold' : 'buy';
                                this.fireEvent('itemclick', this, action, view, rowIndex, colIndex, item, e);
                            }
                        }
                    ]
                }