PDA

View Full Version : Ext.getCmp(id) undefined



kishorkoli8
22 Jan 2015, 7:56 PM
Hello experts,
I am developing an application and have two grids as A and B, on click of an action button in grid B, I am trying to change the action column icon of particular row in grid A. I have tried it as follows

In handler of grid B;s action column,

var grid = Ext.getCmp('stockgrid'); //stockgrid is Grid A's Id
var button = Ext.query('td.x-action-col-cell img', grid.getNode(index))[2];
button.src = '.../add.png';

But I am gettingExt.getCmp('stockgrid'); asundefined.

Please help

skirtle
22 Jan 2015, 9:25 PM
Never use static ids for components. It's incredibly bad practice.
Grid panels don't have a getNode method. Are you sure it isn't this that's failing?
From what little information you've provided I'd suggest using a suitable getClass function on your column items instead. Either that or use the CSS cascade and iconCls to change the icon (possibly in conjunction with getRowClass).

kishorkoli8
22 Jan 2015, 9:36 PM
Thanks for replying skirtle,
and YES, Ext.grid.panel do hva getNode() method, and I have used it in the same application,
I think I am close to the solution with this approach, can you please help me to resolve the mentioned issue, it will be very helpful to me if you do so.

Thanks again

skirtle
22 Jan 2015, 9:54 PM
and YES, Ext.grid.panel do hva getNode() method, and I have used it in the same application,

Ext.grid.View has a getNode method but not Ext.grid.Panel.

Have you tried logging out the value of the variable grid to confirm it is undefined? The rest of the code is pretty academic if it is.


I think I am close to the solution with this approach, can you please help me to resolve the mentioned issue, it will be very helpful to me if you do so.

I feel a Turkish proverb coming on...


No matter how far you have gone on a wrong road, turn back.

Stop trying to do things with a jQuery-esque hack. Clicking the icon should make a change to the record (the model for the row) that you use to update the CSS classes accordingly.

The only reason I can think of for using a non-CSS approach is if there are so many icons that you can't feasibly include them all in your CSS.

kishorkoli8
22 Jan 2015, 10:04 PM
ok will follow the way u suggested in first answer,
Thank you so much