PDA

View Full Version : Can sencha touch do this?



johnstontrav
27 Apr 2011, 1:56 AM
Hi,

I have a native app that i want to convert over to sencha touch. It has a custom list view with some buttons and inputs, see image below for example:

25803

Here's how is works:
-------
The user taps the suggested button (3 in this case) and the input value is set to 3. If the user taps the Actual input box the numerical keyboard is shown and they type in a value. Once the input value has been entered or changed the data store is updated. Then they move to the next row.


What I have in sencha so far:
------
I have managed to add a button and the input to the list view and attach an action when the button is selected, but i don't know how to set the input text with the button value. Here is how i have added the button and input.



...
itemTpl: 'Suggested: <span class="button">{suggested}</span> Actual: <input type="text" id="input_{id}" value="{actual}">'
...


I also don't know how to show the keyboard when the user taps the input box.

I would prefer to use Ext.form for the inputs, but I don't know how.

Can anyone help me out?

happysokki
27 Apr 2011, 6:19 AM
You could try the following:


itemTpl: 'Suggested: <span class="button">{suggested}</span> Actual: <input type="number" id="input_{id}" value="{actual}">',
listeners: {
itemtap: function(list, index, element, e){
if (e.getTarget().className == 'button') {
var store = list.getStore(), record = store.getAt(index);
record.set('actual', record.get('suggested'));
}
}
}

johnstontrav
27 Apr 2011, 2:25 PM
thanks happysokki, that worked.