PDA

View Full Version : Tree populate FormPane



christophe67
19 Jul 2010, 1:37 AM
I need to populate a formPanel when I click on the node of the treePanel,
listeners: {
click: function(n){
var contactForm =Ext.getCmp('contactForm');
en_tete_job.load({ params: { 'id': n.attributes.text} });
}}

I use this code it's run for reload json but I can not fill up the form.

Condor
19 Jul 2010, 1:43 AM
Where should the data for the form come from?

christophe67
19 Jul 2010, 1:50 AM
I use a JsonStore

Condor
19 Jul 2010, 2:56 AM
Are you using the JsonStore for multiple record or only for a single record?

If it only holds a single record, then you shouldn't be using a store at all. Instead, you should simply load the form itself (requires a slightly different syntax in the server response).

christophe67
19 Jul 2010, 3:08 AM
I use JsonStore with multiple record, I have 5 fields in my data to fill up the form
thanks condor

Condor
19 Jul 2010, 3:11 AM
But if the store contains multiple records, how do you know which record to use to load the form?

christophe67
19 Jul 2010, 3:25 AM
This is my JsonStore :

var en_tete_job = new Ext.data.JsonStore({
url: 'data_pagging_jobs.php',
baseParams:{task: "Load"},
root: 'results',
method: 'POST',
fields:[{name: 'date_job', mapping: 'date_job',renderer:Ext.util.Format.dateRenderer('Y-m-d')},
{name: 'departement', mapping: 'departement'},
{name: 'operation', mapping: 'operation'},
{name: 'production', mapping: 'production'},
{name: 'intervenant', mapping: 'intervenant'},
{name: 'indice', mapping: 'indice'}],
autoLoad: false
});

This is load when the node is selected.
And this is a part of my form
var contactForm = new Ext.form.FormPanel({
id:'contactForm',
title: '',
region: 'north',
height: 201,
labelWidth: 130,
buttonAlign: 'center',
items: [
{
xtype: 'datefield',
fieldLabel: 'Label',
name:'date_job',
id:'date_job'
},
{
xtype: 'textfield',
fieldLabel: 'Label',
name:'departement',
id:'departement'
},
{
xtype: 'textfield',
fieldLabel: 'Label',
name:'operation',
id:'operation'
}

how can I select data from my JsonStore and put in my form
Thanks condor

Animal
19 Jul 2010, 4:07 AM
We don't know.

If



en_tete_job.load({ params: { 'id': n.attributes.text} });


really does load multiple Records (and I'm not sure it does), then you must select which one of them to load into the Form.

christophe67
19 Jul 2010, 5:16 AM
You have right, the code you show is just to pass in the url the id
to select the right data in the database. I need to display in the form the answer of jsonStore to the form.

Thanks animal

Condor
19 Jul 2010, 5:29 AM
So you only return a single record? In that case you shouldn't be using a store!

Simply load the form:

formPanel.getForm().load({
url: 'data_pagging_jobs.php',
params: {
task: 'Load',
id: n.attributes.text
}
});
(Note: this requires a slightly different response from the server)