Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the cursor using ExtJS

I would like to set a column of a grid to change cursor to pointer once hovered.

I dunno if its best practice to apply a style to it, you tell me please.

I just cant figure it out.

This is my code and I wish the column would change cursor upon mouse hover.

Ext.define('Ext.grid.Panel', {
store: services,
xtype: 'log',
features: [groupingFeature],
stateId: 'stateGrid',
columns: [
    {
        text: 'URL',
        sortable: true,
        flex: true,
        dataIndex: 'url'
    }
  ]
});

thank you for help

like image 598
John Doe Avatar asked Dec 20 '22 18:12

John Doe


2 Answers

It works for me:

columns: [
{
    text: 'URL',
    sortable: true,
    flex: true,
    dataIndex: 'url',
    renderer: function (val, metadata, record) {
            metadata.style = 'cursor: pointer;'; 
        return val;
    }
}]
like image 174
Zakaria Imtiaz Avatar answered Jan 12 '23 10:01

Zakaria Imtiaz


With most components, one can directly attach CSS snippets alike:

 Ext.define('...', {
    extend: 'Ext.chart.CartesianChart',
    legend: {
        style: 'cursor: pointer;'
    }
});

When using a renderer, one can also attach a CSS class (and whatever styles):

renderer: function (value, meta, record) {
     meta.tdCls += 'x-cursor-pointer'; 
     return value;
}

Ext.grid.column.Column also has a componentCls property: Ext.grid.column.Column#cfg-componentCls and a style property: Ext.grid.column.Column#cfg-style... which would set the style for the the whole column, instead of each indivivual row - or one can combine, by adding a class to the whole column and further classes with the renderer, according to the values (and then use these combined CSS selectors).

like image 38
Martin Zeitler Avatar answered Jan 12 '23 09:01

Martin Zeitler