PDA

View Full Version : Load Form data from JSON Data



thilakmsc
26 Aug 2012, 10:40 PM
Still I'm unable to load field values from Json data.


var FormCopyListDefinition = new Ext.form.Panel({
autoHeight: true,
bodyPadding: 10,
fieldDefaults: { labelAlign: 'right' },
items :
[

{
xtype: 'container',
layout: 'hbox',
items: [
{
xtype : 'textfield',
fieldLabel: 'Name',allowBlank: false,name:'_ListDefinitionName'
//value:Res.d[0]._ListDefinitionName

},


{
xtype : 'textfield',
fieldLabel: 'Description',width:400,Name:'_Description'

}

]
},

{
xtype: 'container',
allowBlank: false,
autoFitErrors: false,
layout: 'column',
defaultType: 'container',
fieldDefaults: {labelAlign: 'right'},
items:
[
{
columnWidth: 0.20,
xtype: 'radiogroup',
vertical: true,
columns: 1,
items: [
{
xtype: 'radiofield', boxLabel: 'Fixed length text', name: '_FileType', inputValue: 1,
listeners:
{
change: function (cb, nv, ov)
{

if (nv) Ext.getCmp('txtDelimiter').disable();

}
}





},
{xtype: 'radiofield', boxLabel: 'Delimited files', name: '_FileType', inputValue: 2,
listeners:
{
change: function (cb, nv, ov)
{

if (nv) Ext.getCmp('txtDelimiter').enable();

}
}

},
{xtype: 'radiofield', boxLabel: 'Excel', name: '_FileType', inputValue: 3,
listeners:
{
change: function (cb, nv, ov)
{

if (nv) Ext.getCmp('txtDelimiter').disable();

}
}

}
]
},
{
columnWidth: 0.15,
items:
[
{xtype: 'component', html: ''},
{xtype: 'textfield',
fieldLabel: 'Delimiter',
id:'txtDelimiter',
allowBlank: false,
name:'_Delimiter',
labelWidth: 50,
size: 1
}
//,{ xtype: 'textfield', name: 'txtDelimiter',fieldLabel: 'Delimiter',width:50,style:'margin-right:5px;width:50px;'}
]
},
{
columnWidth: 0.30,
items:
[

{ xtype: 'checkboxgroup', width: 200,vertical: true, columns: 1,

items: [
{
xtype: 'checkboxfield',
boxLabel: 'Ignore Header Row on Import',
name: '_IgnoreImportHeader'
},
{
xtype: 'checkboxfield',
boxLabel: 'Ignore Footer Record on Import',
name: '_IgnoreImportFooter'
}
]
}

]
},
{
columnWidth: 0.25,
items:
[

{ xtype: 'checkboxgroup', width:200,vertical: true, columns: 1,

items: [
{
xtype: 'checkboxfield',
boxLabel: 'Include Header on Export',
name:'_ExportHeader'
},
{
xtype: 'checkboxfield',
boxLabel: 'Include Contact Fields on Export',
name:'_ExportContactFields'
}
]
}

]
}

]
}
]


});

FormCopyListDefinition.getForm().load
({
url: 'http://118.102.161.169/List/ScriptPage/ScriptPageProxy.aspx/GetDefinition',
params:{ListDefinitionName:selectedItems},
method:'GET'
});

And My JSON Data IS


{'d': [{"_ListDefinitionName":"SampleTable1","_Description":"microtenancy_SampleTable1", "_FileType":0,"_Delimiter":"","_IgnoreImportHeader":true,"_IgnoreImportFooter":false,"_ExportHeader":true,"_ExportContactFields":true}]}

vietits
26 Aug 2012, 11:53 PM
The returned JSON data for <form>.load() should be one record and in the form of {success: true, data: {...}}. So try to return json data as below:


{
"success": true,
"data": {
"_ListDefinitionName":"SampleTable1",
"_Description":"microtenancy_SampleTable1",
"_FileType":0,
"_Delimiter":"",
"_IgnoreImportHeader":true,
"_IgnoreImportFooter":false,
"_ExportHeader":true,
"_ExportContactFields":true
}
}

Also, there is a typo in your _Description field. It should be name: '_Description', not Name: '_Description'

thilakmsc
27 Aug 2012, 9:37 PM
Dear Vietits.,
(http://www.sencha.com/forum/member.php?362966-vietits)

Really Thank you for you help.

Thilak