3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">// Application instance for showing user-feedback messages.
9 var App = new Ext.App({});
11 // Create a standard HttpProxy instance.
12 var proxy = new Ext.data.HttpProxy({
16 // Typical JsonReader. Notice additional meta-data params for defining the core attributes of your json-response
17 var reader = new Ext.data.JsonReader({
18 totalProperty: 'total',
19 successProperty: 'success',
24 {name: 'email', allowBlank: false},
25 {name: 'first', allowBlank: false},
26 {name: 'last', allowBlank: false}
29 // The new DataWriter component.
30 var writer = new Ext.data.JsonWriter();
32 // Typical Store collecting the Proxy, Reader and Writer together.
33 var store = new Ext.data.Store({
35 restful: true, // <-- This Store is RESTful
38 writer: writer, // <-- plug a DataWriter into the store just as you would a Reader
40 write : function(store, action, result, response, rs) {
41 App.setAlert(response.success, response.message);
46 // Let's pretend we rendered our grid-columns with meta-data from our ORM framework.
48 {header: "ID", width: 40, sortable: true, dataIndex: 'id'},
49 {header: "Email", width: 100, sortable: true, dataIndex: 'email', editor: new Ext.form.TextField({})},
50 {header: "First", width: 50, sortable: true, dataIndex: 'first', editor: new Ext.form.TextField({})},
51 {header: "Last", width: 50, sortable: true, dataIndex: 'last', editor: new Ext.form.TextField({})}
54 // load the store immeditately
57 Ext.onReady(function() {
60 // use RowEditor for editing
61 var editor = new Ext.ux.grid.RowEditor({
65 // Create a typical GridPanel with RowEditor plugin
66 var userGrid = new Ext.grid.GridPanel({
67 renderTo: 'user-grid',
75 columns : userColumns,
82 iconCls: 'silk-delete',
90 <div id="prop-Ext.ux.TaskBar.TaskButton-function"></div>/**
93 function onAdd(btn, ev) {
94 var u = new userGrid.store.recordType({
100 userGrid.store.insert(0, u);
101 editor.startEditing(0);
103 <div id="prop-Ext.ux.TaskBar.TaskButton-function"></div>/**
106 function onDelete() {
107 var rec = userGrid.getSelectionModel().getSelected();
111 userGrid.store.remove(rec);