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.
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?