Results 1 to 5 of 5

Thread: Ext.getCmp(id) undefined

  1. #1
    Sencha User
    Join Date
    Jan 2015
    Location
    Pune, India
    Posts
    17

    Default Ext.getCmp(id) undefined

    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

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    1. Never use static ids for components. It's incredibly bad practice.
    2. Grid panels don't have a getNode method. Are you sure it isn't this that's failing?
    3. 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).

  3. #3
    Sencha User
    Join Date
    Jan 2015
    Location
    Pune, India
    Posts
    17

    Default

    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

  4. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    Quote Originally Posted by kishorkoli8 View Post
    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.

    Quote Originally Posted by kishorkoli8 View Post
    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.

  5. #5
    Sencha User
    Join Date
    Jan 2015
    Location
    Pune, India
    Posts
    17

    Default

    ok will follow the way u suggested in first answer,
    Thank you so much

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •