PDA

View Full Version : Change action column icon for single row



kishorkoli8
11 Mar 2015, 11:19 PM
Hello experts,
I need to disable action column icon for a single row.
With the following code, I am able to get action column icon source ,
var myGrid = Ext.getCmp('stockgrid');
myGrid.column[0].items[0].icon ;

But how to get it for a specific row ???:-?

Please help

suzuki1100nz
12 Mar 2015, 1:18 AM
Have a look at - Ext.view.Table

http://docs-origin.sencha.com/extjs/5.0.1/#!/api/Ext.view.Table-method-getRow

and

http://docs-origin.sencha.com/extjs/5.0.1/#!/api/Ext.view.Table-method-getCell

You can get the grid view using grid.getView();

kishorkoli8
12 Mar 2015, 1:34 AM
Have a look at - Ext.view.Table

http://docs-origin.sencha.com/extjs/5.0.1/#!/api/Ext.view.Table-method-getRow

and

http://docs-origin.sencha.com/extjs/5.0.1/#!/api/Ext.view.Table-method-getCell

You can get the grid view using grid.getView();

Hello, thanx foryour reply,

previously iwas trying to get a rows action column icon like,



var myGrid = grid.up('twtabpanelview').down('stockgrid');
var recordIndex = grid.getStore().getAt(rowIndex).get('RowId');


var deleteBttn = Ext.query('td.x-action-col-cell img', myGrid.getView().getNode(recordIndex))[4];




it was always giving me zeroth row back,

I have tried theway you said, and chaned getNode by getRow(),

but itgives me error like




TypeError: myGrid.getView(...).getRow is not a function



Please help with that

suzuki1100nz
12 Mar 2015, 10:21 AM
Without your code and stepping through debugger its a little difficult.
Post your actual code - are you finding the icon in an actioncolumn handler? or is it a button click?

Why are you using getNode instead of getCell() ? I would get the html element for the cell and then find the icon to disable.

If your using an Ext.grid.column.Action then the handler for that passes in the grid view, rowIndex and column index

skirtle
12 Mar 2015, 4:33 PM
Have you considered using the action column's getClass function instead? There's no need to grab any elements, just return the appropriate CSS class from getClass.

kishorkoli8
12 Mar 2015, 7:46 PM
Without your code and stepping through debugger its a little difficult.
Post your actual code - are you finding the icon in an actioncolumn handler? or is it a button click?

Why are you using getNode instead of getCell() ? I would get the html element for the cell and then find the icon to disable.

If your using an Ext.grid.column.Action then the handler for that passes in the grid view, rowIndex and column index


Thanks for your reply Suzuki,
Actually there are two grids and I am trying to change or disable icon of one grids specific row from the handler of another grids action column icon

code for first grids action column,


xtype : 'actioncolumn',
id: 'vercolid',
width: 50,
header : "Add",
items : [ {
icon : 'images/add.png',
tooltip : 'add',
id:'addimageid',
handler: function (grid, rowIndex, colIndex) {
?
var deleteBttn = Ext.query('td.x-action-col-cell img',grid.getNode(rowIndex))[0];
var dltbtn = deleteBttn.src;
var button = dltbtn.substring(dltbtn.lastIndexOf("/")+1);;
if(button == 'add.png') {
var docSelGridStore = grid.getStore();
var rec= docSelGridStore.getAt(rowIndex);
var s = Ext.encode(rec.data);
s = s.substring(s.lastIndexOf("{"),s.lastIndexOf("}") );
s = s + "," + "\"" + "rowindex" + "\"" +":" + "\"" + rowIndex + "\"" + "}";
var attrMapStore = Ext.getStore('mappingStore');
for(var i = 0;i<attrMapStore.getCount();i++) {
s=s.replace(attrMapStore.getAt(i).get('docAttr'), attrMapStore.getAt(i).get('twAttr'));
}
var m =JSON.parse(s);
Ext.getCmp('pagingtoolbarid').store.insert((Ext.getCmp('pagingtoolbarid').store.getCount()+1),m);
deleteBttn.src = 'images/delete.png';
Ext.getCmp('pagingtoolbarid').store.sync();
}
}
}]
?
});
docselectiongrid.headerCt.insert(docselectiongrid.columns.length, verColAddImage);
docselectiongrid.getView().refresh();


and code for the another grids handler


handler: function (grid, rowIndex, colIndex) {
var myGrid = grid.up('twtabpanelview').down('stockgrid');
var recordIndex = grid.getStore().getAt(rowIndex).get('RowId');
//var selec = myGrid.getStore().getAt(recordIndex);

var deleteBttn = Ext.query('td.x-action-col-cell img', myGrid.getView().getNode(recordIndex))[4];
alert(deleteBttn.src);
deleteBttn.src = 'images/ADD.png';
}




can you please provide an example to use getCell instead.

kishorkoli8
12 Mar 2015, 7:53 PM
Have you considered using the action column's getClass function instead? There's no need to grab any elements, just return the appropriate CSS class from getClass.

Thanks for your reply,

Can you please provide me a small snippet of how to use getClass of one action clumn in another action clumns handler

skirtle
13 Mar 2015, 5:36 AM
jj8

kishorkoli8
17 Mar 2015, 9:55 PM
Thank you skirtle....this worked for me.