Search code examples
iossencha-touchsencha-touch-2

Set button text based on data attribute in Sencha Touch?


I have an Ext.List that displays a collection of In-App purchases like a list of songs in the iOS iTunes app. Each item has a "buy" button justified on the right, which should show the price of the item stored in the Ext.data.Record.

How can I set the text of the button to show the price string as stored in the data record? I am only aware of hard-coding a value into the Ext.Button's "text" attribute. Maybe there is a way to do this with a callback?

Thank you so much!


Solution

  • You can just get a reference to the button and then call the setText() method. So your code might look something like this:

    var button = viewWithButton.down('#buttonid');
    button.setText(record.get('price'));