Armance
Armance

Reputation: 5390

EXTJS4: how to set value of displayfield dynamically (from server data)

I want to add an account Info section to my app, it would contain name and role of the current user

In my server side i can get those infos, but i dont know how to send them from server to my form and display them in a displayfield

The only way I know of dynamically populating data from sever is in grids using store.

How can i do this please?

my extjs code:

xtype: 'form',
            border: false,
            frame: true, 
            height: 100,
            width: 400,
            layout: 'column',
            items: [
                    {   columnWidth: .5,
                        border: false,
                        frame: true, 
                        height: 50,
                        defaults: { labelStyle: 'font-size:11px' },
                        items: [{
                            xtype: 'displayfield',
                            id: 'Customer',
                            fieldLabel: 'Customer',
                            value: '<span style="color:blue;font-size:9px">IBM</span>'
                        }]

                    }, {
                        columnWidth: .5,
                        border: false,
                        frame: true,
                        margin: '0 0 0 8',
                        height:50,
                        defaults: { labelStyle: 'font-size:11px' },
                        items: [
                         {
                             xtype: 'displayfield',
                             id: 'role',
                             fieldLabel: 'Role',
                             value: '<span style="color:blue;font-size:9px">Admin</span>'
                         }
                        ]

Feel free to ask for more details if its not clear enough.

Thank you

Upvotes: 1

Views: 10155

Answers (1)

dbrin
dbrin

Reputation: 15673

Use form.loadRecord(record). Any fields whose name mathches your model fields will be set.

To get the record you can use MyModel.load() see the sencha guides for this http://docs.sencha.com/ext-js/4-0/#!/guide/data .

Upvotes: 2

Related Questions