3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
7 // Application instance for showing user-feedback messages.
8 var App = new Ext.App({});
10 // Create a standard HttpProxy instance.
11 var proxy = new Ext.data.HttpProxy({
15 // Typical JsonReader. Notice additional meta-data params for defining the core attributes of your json-response
16 var reader = new Ext.data.JsonReader({
17 totalProperty: 'total',
18 successProperty: 'success',
23 {name: 'email', allowBlank: false},
24 {name: 'first', allowBlank: false},
25 {name: 'last', allowBlank: false}
28 // The new DataWriter component.
29 var writer = new Ext.data.JsonWriter();
31 // Typical Store collecting the Proxy, Reader and Writer together.
32 var store = new Ext.data.Store({
34 restful: true, // <-- This Store is RESTful
37 writer: writer, // <-- plug a DataWriter into the store just as you would a Reader
39 write : function(store, action, result, response, rs) {
40 App.setAlert(response.success, response.message);
45 // Let's pretend we rendered our grid-columns with meta-data from our ORM framework.
47 {header: "ID", width: 40, sortable: true, dataIndex: 'id'},
48 {header: "Email", width: 100, sortable: true, dataIndex: 'email', editor: new Ext.form.TextField({})},
49 {header: "First", width: 50, sortable: true, dataIndex: 'first', editor: new Ext.form.TextField({})},
50 {header: "Last", width: 50, sortable: true, dataIndex: 'last', editor: new Ext.form.TextField({})}
53 // load the store immeditately
56 Ext.onReady(function() {
59 // use RowEditor for editing
60 var editor = new Ext.ux.grid.RowEditor({
64 // Create a typical GridPanel with RowEditor plugin
65 var userGrid = new Ext.grid.GridPanel({
66 renderTo: 'user-grid',
74 columns : userColumns,
81 iconCls: 'silk-delete',
92 function onAdd(btn, ev) {
93 var u = new userGrid.store.recordType({
99 userGrid.store.insert(0, u);
100 editor.startEditing(0);
105 function onDelete() {
106 var rec = userGrid.getSelectionModel().getSelected();
110 userGrid.store.remove(rec);