PDA

View Full Version : how to get value in textfield?



big
15 Feb 2010, 1:17 AM
how to get value in textfield?

i want to compare value and choose same value(in php) to show on grid.

bclinton
15 Feb 2010, 1:37 AM
Have you tried the getValue() method of Ext.form.TextField?

big
15 Feb 2010, 1:43 AM
i tried by this code


store.reload({
station: Ext.getCmp("station").getValue()

});


but not work.

big
15 Feb 2010, 1:47 AM
this is my code
it is form before choose in php and show on grid(data show on grid when i click search)


var simpleForm = new Ext.FormPanel ({
labelWidth: 75,
method: 'POST',//////////////////
renderTo: "simple-form",
frame: true,
title: 'Search',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
items: [{
fieldLabel: 'Station',
name: 'station',
id: 'station',
xtype: 'textfield',
allowBlank:false

}],
buttons: [{
text: 'Search',
handler: function () {
store.reload({
station: Ext.getCmp("station").getValue()


});



}
},{
text: 'Cancel',
handler: function () {
simpleForm.getForm().reset();
}
}]
});

bclinton
15 Feb 2010, 1:54 AM
And what does Ext.getCmp("station") return? getValue() isn't going to work if Ext.getCmp("station") is not returning a valid reference to your TextField.

You have firebug installed, right? before the store.reload statement, try this:


console.log(Ext.getCmp("station"));

You should see a reference to your textfield in the Firebug console. If you do not, then I think your quesation will become, "How do I get a reference to my TextField so I can get its value?"

Eugen_
15 Feb 2010, 2:22 AM
Hi big,

You have an error in code:



store.reload({
params: {
station: Ext.getCmp("station").getValue()
}
});

big
15 Feb 2010, 2:27 AM
thank you very much.

big
15 Feb 2010, 2:33 AM
Thank you http://www.yui-ext.com/forum/image.php?u=108295&dateline=1265734927 (http://www.yui-ext.com/forum/member.php?u=108295) Eugen_ (http://www.yui-ext.com/forum/member.php?u=108295)

big
15 Feb 2010, 2:43 AM
thank you very much.

big
15 Feb 2010, 2:43 AM
thank you Eugen.

big
15 Feb 2010, 9:40 AM
how to get value in datefield?

Eugen_
15 Feb 2010, 10:09 AM
how to get value in datefield?
same as the textfield

maybe, do you need a date formatting? Use the dateFormat method, like this


yourDateField.getValue().dateFormat('Y-m-d'),

big
15 Feb 2010, 10:28 AM
how to do it?

Eugen_
15 Feb 2010, 10:40 AM
how to do it?
I do not understand your question. Do what?

bclinton
15 Feb 2010, 10:44 AM
how to do it?

You implement it exactly as you implemented the getValue() for your textfield.

Will it work? Probably, but we can't be sure. But we can be sure that you're never going to learn to do it for yourself if you don't at least try.

Try it and if it doesn't work then post code showing that you've at least tried to implement it.

big
15 Feb 2010, 10:46 AM
sorry, i am not good english.

i want to ask you that " where put this code
yourDateField.getValue().dateFormat('Y-m-d')".

big
15 Feb 2010, 10:55 AM
i think maybe my database isn't form date for support datefield.

bclinton
15 Feb 2010, 10:56 AM
sorry, i am not good english.

i want to ask you that " where put this code
yourDateField.getValue().dateFormat('Y-m-d')".

Well, if you want to send it as a parameter like you are doing with your text field, put it with the other parameter you are already sending:



store.reload({
params: {
station: Ext.getCmp("station").getValue(),
date_parameter: yourDateField.getValue().dateFormat('Y-m-d')
}
});

Eugen_
15 Feb 2010, 11:04 AM
sorry, i am not good english.
I'm not good at English too, therefore I see the API Documentation and the samples first. :)

big
15 Feb 2010, 11:24 PM
thank you for help me.

i knew then that it use
datefrom: Ext.getCmp("datefrom").getRawValue()

it's work.