O'Reilly logo

Ext JS 4 Web Application Development Cookbook by Stuart Ashworth, Andrew Duncan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading server side data into a combobox

A combobox's selection list can be loaded from locally defined data (in JavaScript) or remotely from a web server. This recipe provides an introduction on how to load JSON data from a server into the combobox's selection list.

Getting ready

The following recipe requires you to interact with a web server. Please ensure you have a running web server for serving the users.json file. The file should contain:

{
    "success": true,
    "users": [{
        "fullName": "Joe Bloggs",
        "userID": 1
    }, {
        "fullName": "John Smith",
        "userID": 2
    }]
}

How to do it...

  1. Start by defining a model.
    Ext.define('User', {
        extend: 'Ext.data.Model',
        fields: [{
            type: 'string',
            name: 'fullName'
        }, {
            type: 'int',
            name: 'userID'
        }]
    });
  2. Create an Ext.data.Store ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required