Book Image

Learning Ext JS_Fourth Edition

Book Image

Learning Ext JS_Fourth Edition

Overview of this book

Table of Contents (22 chapters)
Learning Ext JS Fourth Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

A basic grid


Once we have defined our data package (model and store), we are ready to create our first grid. In this example, we are going to create the customers grid, as shown in the following code:

Ext.onReady(function(){
  var myStore = Ext.create("Myapp.store.customers.Customers");
  var myGrid = Ext.create('Ext.grid.Panel',{
    height: 250,
    width:  800,
    title: 'My customers',
    columns: [{
      width: 70,
      dataIndex: 'id',// *** model field name
      text: 'Id'
    },{
      width: 160,
      dataIndex: 'name', //***
      text: 'Customer name'
    },{
      width: 110,
      dataIndex: 'phone',//***
      text: 'Phone'
    },{
      width: 160,
      dataIndex: 'website',//***
      text: 'Website'
    },{
      width: 80,
      dataIndex: 'status',//***
      text: 'Status'
    },{
      width: 160,
      dataIndex: 'clientSince',//***
      text: 'Client Since'
    }],
    store: myStore,
    renderTo: Ext.getBody()
  });
});

In this code, we created a grid that...