PDA

View Full Version : EXT JS 4



LIQINAU
19 Dec 2012, 2:15 AM
We need to load data from JSON into a form panel which is having a displayfield using MVCThis the code that we had written. We are newbie to EXT JS 4 using MVCxtype: 'form', x : 400, y : 35, id:'formpanel', title: 'Form Panel', width: 350, height: 200, style: 'margin: 50px', reader: new Ext.data.JsonReader({ type: 'json', root: 'data', fields: [ {name: 'firstName', type: 'string'}, {name: 'lastName', type: 'string'} ] }), items: [{ xtype: 'container', layout: 'hbox', items: [{ fieldLabel: 'First Name', xtype: 'displayfield', name: 'firstName', readOnly: true, flex: 1 }, { fieldLabel: 'Last Name', xtype: 'displayfield', name: 'lastName', readOnly: true, flex: 1 }] }], In the controller part we had written these formPanel.getForm().load({ method:'GET', url:'app/data/form.json', //URL that produces a JSON result success: function(response, options) { formPanel.getForm().setValues(Ext.JSON.decode(response.data)); }, failure: function (response, options) { } });As we are executing this code values are not getting displayedform.json {"data":[{"firstName":"System","lastName":"Administrator"}]}

friend
19 Dec 2012, 5:45 AM
Sorry, but your code sample is near impossible to read. Please use code tags and indent properly.

From looking at your sample, it appears that you have an items[] collection jammed inside your JsonReader, where this is not valid code.

Read the Forms Documentation (http://docs.sencha.com/ext-js/4-1/#!/guide/forms) as it has plenty of functional code samples that illustrates exactly what you're trying to do. In particular, see the Handling Data section.