1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    219
    Answers
    10
    Vote Rating
    5
    webfriend13 is on a distinguished road

      0  

    Default Unanswered: Adding event handler for dynamically added button

    Unanswered: Adding event handler for dynamically added button


    Hi All,

    I have added a button to a grid column using following link:
    http://techmix.net/blog/2010/11/25/a...sing-renderer/

    While I am able to add the button, I want to show a image to the button based on certain condition. Where should I write code to handle this condition. Basically I first want to check the condition and then using iconCls config I want to set the image.

    I have a store which have number between 1 to 50. When user clicks on a button, I open a window and in a grid, I show button (one button for each number in each row). The button have a image which show add symbol stating the item is not been added. Now user can click on any button and as soon as he clicks the button, I should change the button image to minus and should add the record to SelectedStore.


    Now the next time the image is loaded, I should search in SelectedStore and if that item is already been added, the image should show minus symbol.

    I want to understand where can I write this logic of checking for values in another store and then applying the image.

    Thanks in advance.

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,568
    Answers
    539
    Vote Rating
    307
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    You may find it easier to use this UX:

    http://www.sencha.com/forum/showthread.php?148064

    The article you referenced fails to mention the potential for memory leaks. Unless you destroy those button components yourself they will leak. The UX above handles that automatically.

    The title of this thread is about event handlers, yet your question seems to be about icons. It's a little unclear what you're trying to do. If you just want to set the icon based on some criteria, isn't that just the same as setting the text?

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    219
    Answers
    10
    Vote Rating
    5
    webfriend13 is on a distinguished road

      0  

    Default


    Hi Skirtlte,

    I have updated the problem statement. Thank you.

  4. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,568
    Answers
    539
    Vote Rating
    307
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    If clicking the button causes the data to change in the record that is used to render that grid row then it will cause it to re-render. This makes it pretty straightforward to switch the icon.

    If clicking the button updates data in a different store then the grid won't re-render. In that case you've got two options. Either force it to re-render manually, or call setIconCls on the button.

Thread Participants: 1