View Full Version : Ext Js 4.1 'addCls' method

21 Aug 2012, 10:40 PM
I have 'color palette' through which I am getting selected color. Also, I am able to get cell of selected row and I want to apply 'selected color' from color palette to selected row's cell.
.color {
font-weight: bold;
------'00FF00' is the color selected from color palette.

Error : 'addCls' method is not supported for cell.

Thanking You in advance

22 Aug 2012, 2:16 AM
Hi mandardadpe,
Try the code given below to get the selected cell of grid and then apply your class to that cell:
Also add selType:'cellmodel' config to your grid panel .

listeners: {
cellclick: function (table,td,cellIndex,record,tr,rowIndex,e) {
var cell = this.view.getCellByPosition({row: rowIndex, column: cellIndex});
cell.addCls('color'); // add your class name here.

22 Aug 2012, 5:16 AM
Yeah Its working but, I want to pick color from color palette and then set it to cell of selected row of tree grid. I have also written code to select cell of selected row.
I want to write "addCls" method in handler of color palette.

How to get rowIndex and cellIndex of selected row???
I have done code as:

var idx = grid.getSelectionModel().getSelection();


but it is giving 'undefined' in alert...

Thank You

22 Aug 2012, 10:43 PM
Hello sword-it (http://www.sencha.com/forum/member.php?427588-sword-it),

Your code has worked for me, please tell me how to get rowIndex and cellIndex of tree grid selected row ?
I have searched a lot ,but I am not able to get rowIndex and cellIndex.
Please help...

Thanking You in advance...