PDA

View Full Version : Sending data from textfield



MalcolmHaslam
1 Jul 2009, 4:26 PM
Im new to extjs and i have a simple problem,
Im trying to fill a grid with a simple search. the search value is in a text box. and the grid is filled with the folowing datastore:



var gantt_searchtask_datastore = new Ext.data.Store( {

id :'gantt_searchtask_datastore',
proxy :new Ext.data.HttpProxy( {
url :'./php/controller.php',
method :'POST'
}),
baseParams : {

task :"LIST_SEARCHTASKS",
name :'Test'//Ext.get('search_task_name').dom.value
},...
This gets all values from the DB with "Test" in their name. instead of "Test" i want the value from the textbox to be the search value.
I also made a test popup message with:

Ext.MessageBox.alert('test',Ext.get('search_task_name').dom.value);

This works perfectly and displays the value of my combo.

Why can't i use the Ext.get('search_task_name').dom.value instead of ''Test"???:((

here is the code for "search_task_name"


var search_task_name = new Ext.form.TextField( {
id :'search_task_name',
fieldLabel :'Nombre',
allowBlank :true,
anchor :'60%',
value: ''
});
Thank you in advance

Lukman
1 Jul 2009, 4:42 PM
If you do:

baseParams : {
task : "LIST_SEARCHTASKS",
name : Ext.get('search_task_name').dom.value
}
you are embedding the value of the textfield statically at the creation of the store. Meaning if the textfield contains "Yes" at instantiation, the "name" parameter will get that value, and no it doesn't change if the textfield value is changed.

If you want the parameter to follow what the textfield value is, don't put it in the baseParams, instead pass it into the store's load() function call:

gantt_searchtask_datastore.load({
name : Ext.get('search_task_name').dom.value
});

MalcolmHaslam
2 Jul 2009, 8:09 AM
unfortunately i couldn't get it to work that way. I found the answer by adding the parameters before the load and not as part of the sotore..


gantt_searchtask_datastore.baseParams = {task :"LIST_SEARCHTASKS",
name :Ext.get('search_task_name').dom.value};
gantt_searchtask_datastore.load();