Load treegrid data dyanamically from a json property file in extjs - extjs

Treegrid is not getting rendered properly. Here is the code:
treeGrid.js :
Ext.define('App.view.DBStatusGrid', {
extend : 'Ext.container.Container',
xtype : 'app-DB-grid',
layout : 'vbox',
items : [
{
xtype : 'container',
cls : 'boxTitle',
html : 'DB Details'
},
{
xtype : 'treepanel',
singleExpand: true,
useArrows:true,
rootVisible:false,
columns: [
{text: 'Server Status', dataIndex: 'serverStatus' , width: 80,},
{ xtype: 'treecolumn',text: 'Server Name', dataIndex: 'serverName' , width: 140},
{ text: 'Instance Status', align:'center', dataIndex: 'instanceStatus',width: 80,},
{text: 'Instance Name', align:'center', dataIndex: 'instanceName',width: 140}
]
}
]
});
property.json :
"data":[
{
"serverStatus": "active",
"serverName":"rg0C1",
"iconCls":"task-folder",
"expanded":false,
"data": [
{
"instanceStatus": "active",
"instanceName":"OA1",
"leaf":true,
"iconCls":"no-icon"
}
]
}
]
Creating store
Ext.define('App.view.InnerContainerView', {
extend : 'Ext.container.Container',
xtype : 'app-inner-ContainerView',
config : {
component : 'NONE',
parentView : ''
},
initComponent : function() {
var parentView = this.getParentView();
this.items = [
{
xtype : 'container',
layout: 'card',
items : [
{
xtype: 'app-DB-grid',
parentView: parentView,
listeners :{
render : function(){
var store = Ext.create('Ext.data.TreeStore',
{
model: 'App.model.treeModel',
autoLoad: true,
proxy: {
type: 'ajax',
url:'app/data/property.json',
reader: {
type: 'json',
root : 'data'
}
},
root :{
expanded :true
}
});
this.down('treepanel').setRootNode(store.getRootNode()); // I am getting my treegrid,and setting the rootnode.
}
]
}
]
this.callParent();
});
My Problem :
From the json property file,only serverName is getting displayed in the treegrid.When I try to expand the serverName,it is not getting expanded.Please help me resolve this issue.Please point me to the correct direction if I am going wrong somewhere.Any help would be appreciated.Thanks.

What about having the store available before the component is created?
Ext.widget({
renderTo: Ext.getBody(),
xtype : 'treepanel',
singleExpand: true,
useArrows:true,
rootVisible:false,
columns: [
{text: 'Server Status', dataIndex: 'serverStatus' , width: 80,},
{xtype: 'treecolumn',text: 'Server Name', dataIndex: 'serverName' , width: 140},
{text: 'Instance Status', align:'center', dataIndex: 'instanceStatus',width: 80,},
{text: 'Instance Name', align:'center', dataIndex: 'instanceName',width: 140}
]
,store: Ext.create('Ext.data.TreeStore', {
model: 'App.model.treeModel',
autoLoad: true,
proxy: {
type: 'ajax',
url:'property.json',
reader: {
type: 'json',
root : 'data'
}
},
root :{
expanded :true
}
})
});
I assumed from the presence of the xtype that you didn't define a class for that component, but that could also be done:
Ext.define('My.TreePanel', {
extend: 'Ext.tree.Panel',
singleExpand: true,
useArrows:true,
rootVisible:false,
columns: [
{text: 'Server Status', dataIndex: 'serverStatus' , width: 80,},
{xtype: 'treecolumn',text: 'Server Name', dataIndex: 'serverName' , width: 140},
{text: 'Instance Status', align:'center', dataIndex: 'instanceStatus',width: 80,},
{text: 'Instance Name', align:'center', dataIndex: 'instanceName',width: 140}
]
// Providing only configuration (as opposed to a store instance) in order for
// each tree to have its own store instance
,store: {
model: 'App.model.treeModel',
autoLoad: true,
proxy: {
type: 'ajax',
url:'property.json',
reader: {
type: 'json',
root : 'data'
}
},
root :{
expanded :true
}
}
});
Ext.create('My.TreePanel', {
renderTo: Ext.getBody()
});
Or this way, that would allow us to be more dynamic with the store creation:
Ext.define('My.TreePanel', {
extend: 'Ext.tree.Panel',
singleExpand: true,
useArrows:true,
rootVisible:false,
columns: [
{text: 'Server Status', dataIndex: 'serverStatus' , width: 80,},
{xtype: 'treecolumn',text: 'Server Name', dataIndex: 'serverName' , width: 140},
{text: 'Instance Status', align:'center', dataIndex: 'instanceStatus',width: 80,},
{text: 'Instance Name', align:'center', dataIndex: 'instanceName',width: 140}
]
,initComponent: function() {
// Creating store instance myself at creation time
this.store = Ext.create('Ext.data.TreeStore', {
model: 'App.model.treeModel',
autoLoad: true,
proxy: {
type: 'ajax',
url:'property.json',
reader: {
type: 'json',
root : 'data'
}
},
root :{
expanded :true
}
});
// Don't forget to call the superclass method!
this.callParent(arguments);
}
});
Ext.create('My.TreePanel', {
renderTo: Ext.getBody()
});

Related

How to configurate Ext.grid.plugin.Editable buttons?

I requires Ext.grid.plugin.Editable in my grid. Now I want to change classes inside default panel, witch slides right for editing of row.
But I don't understand how I to manage submit and delete button function (for example I want to define POST for submit button).
toolbarConfig - doesn't work
Ext.define('Foresto.model.EditListRenters', {
extend: 'Ext.grid.Grid',
xtype: 'rentlist',
requires: [ //some plugins and models
],
frame: true,
store: {
model: 'Foresto.model.RentsListModel',
autoLoad: true,
pageSize: 0,
proxy: {
type: 'ajax',
url: '/api/renter/',
reader: {
type: 'json',
rootProperty: 'results'
}
}
},
plugins: [{
type: //someplugins}
],
/* toolbarConfig: {
xtype:'titlebar',
docked:'top',
items:[{
xtype:'button', // it is don't work
ui:'decline',
text:'decline',
align: 'right',
action:'cancel'
}]
}, */
columns: [{
text: 'id',
dataIndex: 'id'
}, {
text: 'document',
dataIndex: 'document',
editable: true,
flex: 1
}, {
text: 'document_num',
dataIndex: 'document_num',
editable: true
}, {
text: 'legal_type',
dataIndex: 'legal_type',
editable: true
}, {
text: 'fio_represent',
dataIndex: 'fio_represent',
editable: true
}, {
text: 'position_represent',
dataIndex: 'position_represent',
editable: true,
}, {
text: 'certificate',
dataIndex: 'certificate',
editable: true,
}]
});
Here is an example of a grid with a custom form:
https://fiddle.sencha.com/#view/editor&fiddle/2ojt
// model
Ext.define('Fiddle.model.Document', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}, {
name: 'document',
type: 'string'
}, {
name: 'type',
type: 'string'
}]
});
//view (grid)
Ext.define('Fiddle.view.DocumentGrid', {
extend: 'Ext.grid.Panel',
xtype: 'documentlist',
store: {
model: 'Fiddle.model.Document',
data: [{
id: 1,
document: 'My First Doc',
type: 'pdf'
}, {
id: 2,
document: 'My Second Doc',
type: 'pdf'
}]
},
columns: [{
text: 'id',
dataIndex: 'id'
}, {
text: 'Document',
dataIndex: 'document',
flex: 1
}, {
text: 'Type',
dataIndex: 'type',
}]
});
var form = Ext.create('Ext.form.Panel', {
title: 'Form',
region: 'east',
layout: {
type: 'vbox',
algin: 'stretch'
},
collapsible: true,
bodyPadding: 10,
hidden: true,
items: [{
xtype: 'textfield',
name: 'document',
fieldLabel: 'Document'
}, {
xtype: 'combo',
name: 'type',
fieldLabel: 'type',
store: ['pdf', 'doc', 'docx', 'odf']
}],
buttons: [{
text: 'Save',
handler: function () {
form.updateRecord();
form.hide();
}
}]
});
var grid = Ext.create('Fiddle.view.DocumentGrid', {
title: 'Document Grid',
region: 'center',
listeners: {
selectionchange: function (selModel, selection) {
if (Ext.isEmpty(selection)) {
form.hide();
return;
}
form.loadRecord(selection[0]);
form.show();
}
}
});
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
layout: 'fit',
layout: 'border',
width: 600,
height: 600,
items: [
grid, form
]
});
}
});

EXT JS how come the cellmodel are not editable?

Ext.define('RouteFareModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'Rate_ID', type: 'number'},
{name: 'Route_Fare' , type: 'int'},
'From_LocationName',
'To_LocationName',
'From_LocationID',
'To_LocationID',
'from_name',
'to_name',
'Route_ID',
'Normal_Rate',
'Discounted_Rate']
});
var RouteFareStore = Ext.create('Ext.data.JsonStore', {
model: 'RouteFareModel',
storeId: 'RouteFareStore',
autoLoad: false,
sorters: [{
property: 'Route_Fare',
direction: 'ASC'
}],
proxy: {
type: 'ajax',
url: 'get-routefare.php',
api: {
create: 'insert-routeseq.php',
//read: 'http://visual04/ModuleGestion/php/Pays.php?action=read',
update: 'update-routeseq.php',
//destroy: 'http://visual04/ModuleGestion/php/Pays.php?action=destroy'
},
actionMethods: 'POST',
baseParams: {
_id : 0,
},
reader: {
type: 'json',
idProperty: '_id'
},
writer: {
type: 'json',
id: '_id'
}
}
});
var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
Ext.define('MyApp.view.MyGridPanelRouteFare', {
extend: 'Ext.grid.Panel',
id:'MyGridPanelRouteFare',
alias: 'widget.mygridpanelroutefare',
renderTo: Ext.getBody(),
height: window.innerHeight,
width: window.innerWidth/3,
title: 'Route Fare Setting',
selModel: {
selType: 'cellmodel'
},
plugins: [cellEditing],
store: RouteFareStore,
columns: [
{
xtype:'gridcolumn',
width: 120,
dataIndex: 'from_name',
text: 'From Location'
},
{
xtype:'gridcolumn',
width: 120,
dataIndex: 'to_name',
text: 'To Location'
},
{
xtype:'gridcolumn',
width: 80,
dataIndex: 'Normal_Rate',
text: 'Normal Rate'
},
{
xtype:'gridcolumn',
width: 80,
dataIndex: 'Discounted_Rate',
text: 'Discount Rate'
}
],
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
height: 30,
items: [
{
xtype: 'combobox',
id:'cmbFareRouteID',
width: 191,
store: RouteNameStore,
valueField : "_id",
displayField : "Route_Code",
fieldLabel: 'Route Code',
labelWidth: 70,
editable: false,
queryMode: 'local',
listeners: {
select: function( combo, records, eOpts ) {
console.log("Combo selected _id : "+records[0].get('_id'));
RouteFareStore.load({
params:{
_id: records[0].get('_id')
}
});
}
}
},
{
xtype: 'button',
cls: '',
id: 'BtnFareCmbRefresh',
width: 65,
icon: '',
iconCls: 'refresh',
text: 'Refresh'
}
]
},
{
xtype: 'toolbar',
dock: 'top',
height: 30,
items: [
{
xtype: 'button',
cls: '',
id: 'BtnRouteFareSave',
width: 65,
icon: '',
iconCls: 'save',
text: 'Save'
},
{
xtype: 'button',
cls: '',
id: 'BtnRouteFareRefresh',
width: 65,
icon: '',
iconCls: 'refresh',
text: 'Refresh'
}
]
}
]
})
i have add
var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
but the grid cell still not able to editable. why?
{
xtype:'gridcolumn',
width: 80,
dataIndex: 'Normal_Rate',
text: 'Normal Rate',
field: {
xtype: 'numberfield',
allowBlank: false,
minValue: 0,
maxValue: 1000
}
},
must insert field: {} , then the cellmodel able to editable already.

How can i get edited row value from Editable Grid in ExtJs?

I've a HTML page with ExtJs editable grid. Edit is working fine, but i want to get Id field value of the edited row, but can't figured it out... i want to populate another array of values with Id, Name and Email field values of edited ROW...
Ext.onReady(function() {
Ext.create('Ext.data.Store', {
storeId:'myArray',
fields:['id','name', 'email'],
data:{'items':[
{"id":"1", "name":"Lisa", "email":"lisa#ArrayData.com"},
{"id":"2", "name":"Bart", "email":"bart#ArrayData.com"},
{"id":"3", "name":"Homer", "email":"home#ArrayData.com"},
{"id":"4", "name":"Marge", "email":"marge#ArrayData.com"}
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'ArrayData',
store: Ext.data.StoreManager.lookup('myArray'),
columns: [
{header: 'Id', dataIndex: 'id'},
{header: 'Name', dataIndex: 'name', editor: 'textfield'},
{header: 'Email', dataIndex: 'email', flex:1,
editor: {
xtype: 'textfield',
allowBlank: false
}
}
],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners : {
scope: this,
edit: function (theEditor, e, eOpts)
{
console.log();
}
}
})
],
height: 200,
width: 500,
renderTo: Ext.getBody()
});
});
#
#
Thanks #Hariharan and #Dipti for your valuable help... the working code is-
Ext.create('Ext.data.Store', {
storeId:'myArray',
fields:['id','name', 'email'],
data:{'items':[
{"id":"1", "name":"Lisa", "email":"lisa#ArrayData.com"},
{"id":"2", "name":"Bart", "email":"bart#ArrayData.com"},
{"id":"3", "name":"Homer", "email":"home#ArrayData.com"},
{"id":"4", "name":"Marge", "email":"marge#ArrayData.com"}
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
var array_edited=Ext.create('Ext.data.Store', {
storeId:'myArray_edited',
fields:['id','name', 'email'],
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'ArrayData',
store: Ext.data.StoreManager.lookup('myArray'),
columns: [
{header: 'Id', dataIndex: 'id'},
{header: 'Name', dataIndex: 'name', editor: 'textfield'},
{header: 'Email', dataIndex: 'email', flex:1,
editor: {
xtype: 'textfield',
allowBlank: false
}
}
],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners : {
scope: this,
edit: function(editor, e) {
array_edited.add({
id: e.record.get('id'),
name: e.record.get('name'),
email: e.record.get('email')
});
}
}
})
],
height: 200,
width: 500,
renderTo: Ext.getBody()
});
Ext.create('Ext.grid.Panel', {
title: 'ArrayDataEdited',
store: Ext.data.StoreManager.lookup('myArray_edited'),
columns: [
{header: 'Id', dataIndex: 'id'},
{header: 'Name', dataIndex: 'name'},
{header: 'Email', dataIndex: 'email', flex:1
}
],
selType: 'cellmodel',
height: 200,
width: 500,
renderTo: Ext.getBody()
});
Please refer below answer, i hope it will help you.
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners : {
edit : function(editor, e) {
alert("Edited id value : " + e.record.get('id'));
}
}
})
],
check this, you have gridPanel with three columns , using sm you can select values of editables, after save you can call fnctChange function and use the new values.
hope this will help you.
var gridPanel = new Ext.grid.GridPanel({
region : 'west',
width : 360,
height : 250,
trackMouseOver : false,
disableSelection : true,
autoscroll : true,
loadMask : true,
margins : '3 3 3 0',
sm : sm,
viewConfig : {
forceFit : true
},
store : store,
// grid columns
columns : [ sm, {
id : 'columnNames',
header : "<b>Select the column names to be displayed</b>",
dataIndex : 'columnNames',
renderer : renderColumnNames,
width : 360,
sortable : true
}, { id : 'col1ID',
header : "",
dataIndex : 'Col1',
hidden : true,
sortable : true
}, {
id : 'col2ID',
header : "",
dataIndex : 'Col2',
hidden : true,
sortable : true
}]
});
var settingPanelMsg = " <b>Change save</b><br></br>"
var settingPanel = new Ext.Panel({
region : 'center',
width : 390,
height : 250,
margins : '3 0 3 3',
collapsible : true,
html : settingPanelMsg
})
winSetting = new Ext.Window({
title : 'Customize Your chnage',
layout : 'border',
closable : false,
height : 300,
width : 730,
items : [ gridPanel, settingPanel ],
buttons : [ {
text : 'Close',
handler : function(e, target, panel) {
winLibSetting.close();
}
}, {
text : 'Save',
handler : function() {
if (fnctChange() == true) {
winLibSetting.close();
}
}
} ]
});
winLibSetting.show();
function fnctChange() {
var L1 = sm.getSelections();
for (i = 0; i < L1.length; i++) {
var col1value = L1[i].data.col1ID;
if (L1[i].data.col2ID == true) {
var colName= L1[i].data.columnNames;
Ext.MessageBox.alert(' ',
'colName :'+colName);
}
}
return true;
}

ExtJs Grid BufferRenderer doesnot display the grid rows

I want to implement grid bufferrenderer in my simple grid panel that shows a list of information using ExtJS 4.2.1. Without using the bufferrenderer plugin, it shows all the data, but when i used this plugin, my grid contains no data.
This is my grid without using the plugin
This is my grid using the plugin
The grid panel's code is:
Ext.define('MyApp.view.MyPanel', {
extend: 'Ext.panel.Panel',
itemId: 'myPanel',
title: '',
requires: ['Ext.grid.plugin.BufferedRenderer'],
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'gridpanel',
autoRender: true,
autoShow: true,
itemId: 'gridPanel',
title: 'My Grid Panel',
store: 'MyJsonStore',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'id',
text: 'Id'
},
{
xtype: 'gridcolumn',
dataIndex: 'firstName',
text: 'FirstName'
},
{
xtype: 'gridcolumn',
dataIndex: 'middleName',
text: 'MiddleName'
},
{
xtype: 'gridcolumn',
dataIndex: 'lastName',
text: 'LastName'
},
{
xtype: 'gridcolumn',
dataIndex: 'age',
text: 'Age'
},
{
xtype: 'gridcolumn',
dataIndex: 'country',
text: 'Country'
},
{
xtype: 'gridcolumn',
dataIndex: 'city',
text: 'City'
},
{
xtype: 'gridcolumn',
dataIndex: 'street',
text: 'Street'
},
{
xtype: 'gridcolumn',
dataIndex: 'mobile',
text: 'Mobile'
},
{
xtype: 'gridcolumn',
dataIndex: 'phone',
text: 'Phone'
},
{
xtype: 'gridcolumn',
dataIndex: 'zip',
text: 'Zip'
}
],
plugins: 'bufferedrenderer'
/*plugins: {
ptype: 'bufferedrenderer',
trailingBufferZone: 20,
leadingBufferZone: 25
}*/
}
]
});
me.callParent(arguments);
}
});
The Store's code is:
Ext.define('MyApp.store.MyJsonStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.GridModel'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
model: 'MyApp.model.GridModel',
storeId: 'MyJsonStore',
buffered: true,
clearOnPageLoad: false,
clearRemovedOnLoad: false,
leadingBufferZone: 25,
pageSize: 500,
purgePageCount: 10,
trailingBufferZone: 20,
proxy: {
type: 'ajax',
url: 'data/users.json',
reader: {
type: 'json',
root: 'users',
totalProperty: 'total_user'
}
}
}, cfg)]);
}
});
Can anyone help me with this? Thanks
Setting the height property in grid will fix this issue.
height: 300
Make sure that all panels up to the viewport have their layout set to “fit”. Also, region of the grid should be “center”.
I have not tested, but something like this should work:
var grid = Ext.create('MyApp.view.MyPanel', {
layout: 'fit',
region: 'center'
});
var viewport = Ext.create('Ext.container.Viewport', {
renderTo: Ext.getBody(),
items: [
grid
]
});

ExtJS4 grid won't update remote database

For some reason, this configuration of an ExtJS4 grid won't update. When you click on a cell, change a value, it hits the create URL, not the update URL, as defined in the proxy and observed with Firebug in FF4. Strangely, the datachanged event fires after loading the store when the page starts, but not after data has actually changed. Also, the grid send all rows to the create URL.
Can anyone tell me what I am doing wrong?
Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = '/images/extjs4/s.gif';
Ext.tip.QuickTipManager.init();
//Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
Ext.define('VendorError', {
extend: 'Ext.data.Model',
fields: [
{name: 'UnexpSrvID', type: 'int'},
{name: 'VendorID', type: 'int'},
{name: 'VendorName', type: 'string'},
{name: 'VndActID', type: 'int'},
{name: 'VndActNb', type: 'string'},
{name: 'InvoiceID', type: 'int'},
{name: 'VInvNb', type: 'string'},
{name: 'VInvRcptDt', type: 'date', dateFormat: 'Y-m-d' },
{name: 'InvDate', type: 'date', dateFormat: 'Y-m-d' },
{name: 'CodeSpecifier', type: 'string'},
{name: 'Recurrence', type: 'string'},
{name: 'ClientID', type: 'int'},
{name: 'ClientName', type: 'string'},
{name: 'LocID', type: 'int'},
{name: 'LocName', type: 'string'},
{name: 'RecentLocStatus', type: 'string'},
{name: 'RecentLocStatusDate', type: 'date', dateFormat: 'Y-m-d' },
{name: 'UnexpCost', type: 'float'},
{name: 'ConfirmedAmt', type: 'float'},
{name: 'StaffID', type: 'int'},
{name: 'NetworkID', type: 'string'},
{name: 'UnexpStatCode', type: 'string'}
],
proxy: {
type: 'ajax',
simpleSortMode: true,
api: {
read: '/internal/viewVERext_json.asp',
create: '/internal/viewVERext_create.asp',
update: '/internal/viewVERext_update.asp',
destroy: '/internal/viewVERext_destroy.asp'
},
reader: {
type: 'json',
totalProperty: 'total',
successProperty: 'success',
messageProperty: 'message',
root: 'data'
},
writer: {
type: 'json',
writeAllFields: false,
allowSingle: false,
root: 'data'
},
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'REMOTE EXCEPTION',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
}
});
var store = Ext.create('Ext.data.Store', {
model: 'VendorError',
autoLoad: true,
autoSync: true,
pageSize: 20,
remoteSort: true,
listeners: {
// write: function(proxy, operation){
// if (operation.action == 'destroy') {
// main.child('#form').setActiveRecord(null);
// }
// Ext.example.msg(operation.action, operation.resultSet.message);
// }
datachanged: function() {
var report = "";
store.each(
function(rec) {
report = report + rec.dirty + '/';
}
)
alert(report);
}
}
});
// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
store: store,
//stateful: true,
//stateId: 'stateGrid',
columns: [
{ text : 'Vendor',
dataIndex: 'VendorName',
flex : 1
},
{ text : 'Account',
dataIndex: 'VndActNb'
},
{ text : 'Invoice',
dataIndex: 'VInvNb'
},
{ text : 'Invoiced',
dataIndex: 'InvDate',
xtype : 'datecolumn',
align : 'center'
},
{ text : 'Receipted',
dataIndex: 'VInvRcptDt',
xtype : 'datecolumn',
align : 'center'
},
{ text : 'Description',
dataIndex: 'CodeSpecifier'
},
{ text : 'Client',
dataIndex: 'ClientName'
},
{ text : 'Location',
dataIndex: 'LocName'
},
{ text : 'LStatus',
dataIndex: 'RecentLocStatus',
align : 'center'
},
{ text : 'Credit',
dataIndex: 'UnexpCost',
tdCls : 'colyellow',
renderer : Ext.util.Format.usMoney,
align : 'right',
field : { xtype:'textfield', allowBlank:false }
},
{ text : 'Confirmed',
dataIndex: 'ConfirmedAmt',
tdCls : 'colyellow',
renderer : Ext.util.Format.usMoney,
align : 'right',
field : { xtype:'textfield', allowBlank:false }
},
{ text : 'Recurrence',
dataIndex: 'Recurrence',
tdCls : 'colyellow',
align : 'center',
field : {
xtype : 'combobox',
typeAhead: true,
triggerAction: 'all',
selectOnTab: true,
store: [
['once','once'],['1st','1st'],['2nd+','2nd+']
],
lazyRender: true
}
},
{ text : 'CStatus',
dataIndex: 'UnexpStatCode',
tdCls : 'colyellow',
align : 'center',
field : {
xtype : 'combobox',
typeAhead: true,
triggerAction: 'all',
selectOnTab: true,
store: [
<%=cstat_grid%>
],
lazyRender: true
}
},
{ text : 'Owner',
dataIndex: 'NetworkID',
tdCls : 'colyellow',
field : {
xtype : 'combobox',
typeAhead: true,
triggerAction: 'all',
selectOnTab: true,
store: [
<%=staff_grid%>
],
lazyRender: true
}
}
],
layout: 'fit',
height: 500,
renderTo: 'theGrid',
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
dockedItems: [
{ xtype: 'pagingtoolbar',
store: store,
dock: 'bottom',
displayInfo: true
},
{ xtype: 'toolbar',
dock: 'top',
items: [
{ xtype:'button',
text: 'IsDirty()',
handler: function() {
var report = "";
store.each(
function(rec) {
report = report + rec.dirty + '/';
}
)
alert(report);
}
}
]
}
],
viewConfig: {
stripeRows: true
}
});
Ext.EventManager.onWindowResize(grid.doLayout, grid);
});
Turns out the issue is that records added into the grid are detected as "not new" by the value of a unique id field. A kind poster on the Sencha forums pointed me to this.
By default, this field in the model is expected to have a name of 'id'. So, you must either provide a model with a field of 'id', which my model above did not have, or you must override the default column by using the idProperty property of Ext.data.Model. I simply renamed the UnexpSrvId column to id. And, lo and behold, we send updates to update() instead of create().
This is not obvious from the API docs, as many things unfortunately are in this powerful framework.
Because your grid is using the CellEdit mixin you can add a listener to the grid which will commit the changes to your record after editing. So in your grid, add the listeners config option defined as follows...
listeners: {
edit : function(e) {
e.record.commit();
}
}
EDIT: I think you're using the wrong syntax on your proxy... you can only define a reader and writer (by the looks of things)...
Ed Spencer's article on Proxies
ExtJS 4 API Entry on Proxies

Resources