PDA

View Full Version : Calculate value of textfield



Spiff1
23 Oct 2013, 7:49 AM
Hi,

i just want to set the value of a (hidden) textfield to a certain value of my stored data.
I can set the value like:


value: 'Test'

But how do i set the value with a function?

Function would be like:

var myStore= me.getStore('CoolStore');
var myValue = response[0].data.myKey;


and then

value : myValue

Spiff1

riku351
23 Oct 2013, 10:21 AM
Hi,
Here is an example of how to set value.

Lets say that you have a hidden field as below
{
xtype:'hiddenfield',
itemId:'some_value' // use itemId or id as per your preference
}

Now there is some event(like click, dblclick or any other events) on which u want to call a function and u want to set its data.

setHiddenFieldValue: function(){
var myStore= me.getStore('CoolStore');

//Now from this store you can get your desired value by using different methods provided //by Ext.data.Store Class. Those methods can be find(), findBy(), etc.// Or else you can get the value as per your preference.var myValue = response[0].data.myKey;//Finally get the hidden field using Component Query method and sets its value using set//Value()Ext.ComponentQuery.query('hiddenfield[itemId=some_value]')[0].setValue(myValue);}




Thanks