3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
7 Ext.ns('App', 'App.user');
10 * A typical EditorGridPanel extension.
12 App.user.Grid = Ext.extend(Ext.grid.EditorGridPanel, {
13 renderTo: 'user-grid',
19 style: 'margin-top: 10px',
21 initComponent : function() {
28 // relay the Store's CRUD events into this grid so these events can be conveniently listened-to in our application-code.
29 this.relayEvents(this.store, ['destroy', 'save', 'update']);
31 // build toolbars and buttons.
32 this.tbar = this.buildTopToolbar();
33 this.bbar = this.buildBottomToolbar();
34 this.buttons = this.buildUI();
37 App.user.Grid.superclass.initComponent.call(this);
43 buildTopToolbar : function() {
51 iconCls: 'silk-delete',
52 handler: this.onDelete,
60 buildBottomToolbar : function() {
61 return ['<b>@cfg:</b>', '-', {
65 tooltip: 'When enabled, Store will execute Ajax requests as soon as a Record becomes dirty.',
66 toggleHandler: function(btn, pressed) {
67 this.store.autoSave = pressed;
74 tooltip: 'When enabled, Store will batch all records for each type of CRUD verb into a single Ajax request.',
75 toggleHandler: function(btn, pressed) {
76 this.store.batch = pressed;
80 text: 'writeAllFields',
82 tooltip: 'When enabled, Writer will write *all* fields to the server -- not just those that changed.',
83 toggleHandler: function(btn, pressed) {
84 store.writer.writeAllFields = pressed;
93 buildUI : function() {
105 onSave : function(btn, ev) {
112 onAdd : function(btn, ev) {
113 var u = new this.store.recordType({
119 this.store.insert(0, u);
120 this.startEditing(0, 1);
126 onDelete : function(btn, ev) {
127 var index = this.getSelectionModel().getSelectedCell();
131 var rec = this.store.getAt(index[0]);
132 this.store.remove(rec);